Commit e4b5a67f authored by jan.koester's avatar jan.koester
Browse files

copy not recursiv

parent da39333e
Loading
Loading
Loading
Loading
+26 −23
Original line number Diff line number Diff line
@@ -606,7 +606,10 @@ libhtmlpp::HtmlElement & libhtmlpp::HtmlElement::operator=(const libhtmlpp::Elem
}

namespace libhtmlpp {

    void _copy(const libhtmlpp::Element* prev,libhtmlpp::Element *dest,const libhtmlpp::Element *src){

        auto copy_r = [](const libhtmlpp::Element* prev,libhtmlpp::Element *dest,const libhtmlpp::Element *src){
            if(src->getType()==libhtmlpp::HtmlEl && dest->getType()==libhtmlpp::HtmlEl){
                libhtmlpp::HtmlElement *hdest=(libhtmlpp::HtmlElement*)dest;
                libhtmlpp::HtmlElement *hsrc=(libhtmlpp::HtmlElement*)src;
@@ -626,16 +629,16 @@ namespace libhtmlpp {
            }

            dest->_prevElement=(Element*)prev;
        };

        const Element* next=src->nextElement();
        copy_r(prev,dest,src);

        if(next){
            if(next->getType()==HtmlEl)
        for(const Element* curel=src->nextElement(); curel; curel=curel->nextElement()){
            if(curel->getType()==HtmlEl)
                dest->_nextElement= new HtmlElement();
            else if(next->getType()==TextEl)
            else if(curel->getType()==TextEl)
                dest->_nextElement= new TextElement();
            std::thread ct(_copy,src,dest->_nextElement,next);
            ct.join();
            copy_r(src,dest->_nextElement,curel);
        }
    }
};