Commit 0c7fc542 authored by jan.koester's avatar jan.koester
Browse files

fixed

parent 02b5ed0c
Loading
Loading
Loading
Loading
+15 −15
Original line number Diff line number Diff line
@@ -646,30 +646,30 @@ libhtmlpp::HtmlElement::~HtmlElement(){
DELETEELEMENT:

    while(cur){
        if(cur->getType()==HtmlEl){
            if(((HtmlElement*)cur)->_childElement){
        delelm.push(cur);

        if(cur->getType()==HtmlEl && ((HtmlElement*)cur)->_childElement){
            parents.push((HtmlElement*)cur);
            cur=((HtmlElement*)cur)->_childElement;
        }else{
            cur=cur->_nextElement;
        }
    }
        Element *next=cur->_nextElement;
        cur->_firstElement=nullptr;
        cur->_prevElement=nullptr;
        cur->_nextElement=nullptr;
        delelm.push(cur);
        cur=next;
    }

    if(!parents.empty()){
        cur=parents.top();
        ((HtmlElement*)cur)->_childElement=nullptr;
        cur=parents.top()->_nextElement;
        parents.pop();
        goto DELETEELEMENT;
    }

    while(!delelm.empty()){
        if(delelm.top()!=this)
            delete delelm.top();
        Element *del=delelm.top();
        del->_firstElement=nullptr;
        del->_prevElement=nullptr;
        del->_nextElement=nullptr;
        if(del!=this){
            delete del;
        }
        delelm.pop();
    };