[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE_3_1_BRANCH: kdelibs/khtml/xml
From:       Peter Kelly <pmk () post ! com>
Date:       2003-02-03 1:20:24
[Download RAW message or body]

CVS commit by pmk: 

Fixed a memory leak that occurred when an AttrImpl was allocated on-demand
from an AttributeImpl. Both objects had a reference to each other and thus
never got deleted.


  M +10 -1     dom_elementimpl.cpp   1.170.2.1
  M +2 -1      dom_elementimpl.h   1.101.2.1


--- kdelibs/khtml/xml/dom_elementimpl.cpp  #1.170:1.170.2.1
@@ -52,4 +52,12 @@ void AttributeImpl::allocateImpl(Element
 }
 
+void AttributeImpl::detachImpl()
+{
+    if (_impl) {
+        _impl->deref();
+        _impl = 0;
+    }
+}
+
 AttrImpl::AttrImpl(ElementImpl* element, DocumentPtr* docPtr, AttributeImpl* a)
     : NodeBaseImpl(docPtr),
@@ -64,5 +72,4 @@ AttrImpl::AttrImpl(ElementImpl* element,
 AttrImpl::~AttrImpl()
 {
-    assert(m_attribute->_impl == this);
     m_attribute->_impl = 0;
     m_attribute->deref();
@@ -676,4 +683,5 @@ void NamedAttrMapImpl::clearAttributes()
             if (attrs[i]->_impl)
                 attrs[i]->_impl->m_element = 0;
+            attrs[i]->detachImpl();
             attrs[i]->deref();
         }
@@ -780,4 +788,5 @@ void NamedAttrMapImpl::removeAttribute(N
         element->dispatchSubtreeModifiedEvent();
     }
+    attr->detachImpl();
     attr->deref();
 }

--- kdelibs/khtml/xml/dom_elementimpl.h  #1.101:1.101.2.1
@@ -83,4 +83,5 @@ private:
     }
     void allocateImpl(ElementImpl* e);
+    void detachImpl();
 
 protected:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic