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

List:       kde-commits
Subject:    branches/KDE/3.5/kdelibs/khtml/rendering
From:       Maks Orlovich <maksim () kde ! org>
Date:       2008-04-05 17:43:00
Message-ID: 1207417380.553826.31902.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 793952 by orlovich:

Backport Allan's r786289:
"Protect anonymous blocks from being deleted while they are actively 
insterting a new child"

BUG:160249
BUG:160292
BUG:160388


 M  +13 -6     render_container.cpp  
 M  +2 -1      render_object.cpp  
 M  +6 -1      render_object.h  


--- branches/KDE/3.5/kdelibs/khtml/rendering/render_container.cpp #793951:793952
@@ -79,6 +79,8 @@
     kdDebug( 6040 ) << this << ": " <<  renderName() << "(RenderObject)::addChild( " \
                << newChild << ": " <<
         newChild->renderName() << ", " << (beforeChild ? beforeChild->renderName() : \
"0") << " )" << endl;  #endif
+    // protect ourselves from deletion
+    setDoNotDelete(true);
 
     bool needsTable = false;
 
@@ -159,6 +161,8 @@
             static_cast<RenderText*>(newChild)->setText(textToTransform, true);
     }
     newChild->attach();
+
+    setDoNotDelete(false);
 }
 
 RenderObject* RenderContainer::removeChildNode(RenderObject* oldChild)
@@ -545,7 +549,7 @@
 	RenderObject *next = child->nextSibling();
 
 	if ( child->isRenderBlock() && child->isAnonymousBlock() && !child->continuation() \
                &&
-             !child->childrenInline() && !child->isTableCell() ) {
+	     !child->childrenInline() && !child->isTableCell() && !child->doNotDelete()) {
 	    RenderObject *firstAnChild = child->firstChild();
 	    RenderObject *lastAnChild = child->lastChild();
 	    if ( firstAnChild ) {
@@ -560,17 +564,20 @@
 		    child->previousSibling()->setNextSibling( firstAnChild );
 		if ( child->nextSibling() )
 		    child->nextSibling()->setPreviousSibling( lastAnChild );
+		if ( child == firstChild() )
+		    m_first = firstAnChild;
+		if ( child == lastChild() )
+		    m_last = lastAnChild;
 	    } else {
 		if ( child->previousSibling() )
 		    child->previousSibling()->setNextSibling( child->nextSibling() );
 		if ( child->nextSibling() )
 		    child->nextSibling()->setPreviousSibling( child->previousSibling() );
-
+		if ( child == firstChild() )
+		    m_first = child->nextSibling();
+		if ( child == lastChild() )
+		    m_last = child->previousSibling();
 	    }
-	    if ( child == firstChild() )
-		m_first = firstAnChild;
-	    if ( child == lastChild() )
-		m_last = lastAnChild;
 	    child->setParent( 0 );
 	    child->setPreviousSibling( 0 );
 	    child->setNextSibling( 0 );
--- branches/KDE/3.5/kdelibs/khtml/rendering/render_object.cpp #793951:793952
@@ -179,7 +179,8 @@
       m_afterPageBreak( false ),
       m_needsPageClear( false ),
       m_containsPageBreak( false ),
-      m_hasOverflowClip(false)
+      m_hasOverflowClip( false ),
+      m_doNotDelete( false )
 {
   assert( node );
   if (node->getDocument()->documentElement() == node) setIsRoot(true);
--- branches/KDE/3.5/kdelibs/khtml/rendering/render_object.h #793951:793952
@@ -755,6 +755,9 @@
     virtual void deleteInlineBoxes(RenderArena* arena=0) {(void)arena;}
     virtual void detach( );
 
+    void setDoNotDelete(bool b) { m_doNotDelete = b; }
+    bool doNotDelete() const { return m_doNotDelete; }
+
     const QFont &font(bool firstLine) const {
 	return style( firstLine )->font();
     }
@@ -838,9 +841,11 @@
     
     bool m_hasOverflowClip           : 1;
 
-    // ### we have 16 + 25 bits.
+    bool m_doNotDelete 	             : 1; // This object should not be auto-deleted
 
+    // ### we have 16 + 26 bits.
 
+
     void arenaDelete(RenderArena *arena, void *objectBase);
 
     friend class RenderLayer;


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

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