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

fixes fixes fixes

parent 87fc5396
Loading
Loading
Loading
Loading
+54 −26
Original line number Diff line number Diff line
@@ -637,11 +637,12 @@ libhtmlpp::HtmlElement::~HtmlElement(){
    }

    Element *cur=_childElement;
DELETEELEMENT:
    std::stack<Element*> childs;
    std::stack<Element*> delelm;

    if(cur && (cur->_Type==HtmlEl && ((HtmlElement*)cur)->_childElement) ){
    DELETEELEMENT:
    if(cur){
        if((cur->_Type==HtmlEl && ((HtmlElement*)cur)->_childElement) ){
            while(cur){
                Element *next=cur->nextElement();
                cur->_nextElement=nullptr;
@@ -656,11 +657,29 @@ DELETEELEMENT:
        }
        if(!childs.empty()){
            cur=childs.top();
            childs.pop();
            goto DELETEELEMENT;
        }
    }

    while(!delelm.empty()){
        delete delelm.top();
        Element *itm=delelm.top();
        if(itm!=this){
            switch(itm->getType()){
                case HtmlEl:
                    delete (HtmlElement*)itm;
                    break;
                case TextEl:
                    delete (TextElement*)itm;
                    break;
                case CommentEl:
                    delete (CommentElement*)itm;
                    break;
                default:
                    break;
            }
        }
        delelm.pop();
    }
}

@@ -820,12 +839,21 @@ NEWEL:
        Element* next=src->nextElement();

        if(next){
            if(next->getType()==HtmlEl)
            switch(next->getType()){
                case HtmlEl:
                    dest->_nextElement= new HtmlElement();
            else if(next->getType()==TextEl)
                    break;
                case TextEl:
                    dest->_nextElement= new TextElement();
            else if(next->getType()==CommentEl)
                    break;
                case CommentEl:
                    dest->_nextElement= new CommentElement();
                    break;
                default:
                    HTMLException ex;
                    ex[HTMLException::Critical] << "Unknown html element found !";
                    throw ex;
            }
            prev=dest;
            src=next;
            dest=dest->_nextElement;