--- khtml/rendering/render_container.cpp.orig 2008-05-03 09:22:01.000000000 +0200
+++ khtml/rendering/render_container.cpp 2008-05-03 09:22:47.000000000 +0200
@@ -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(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,21 @@
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 = firstAnChild;
+ m_first = child->nextSibling();
if ( child == lastChild() )
- m_last = lastAnChild;
+ m_last = child->previousSibling();
+ }
+
child->setParent( 0 );
child->setPreviousSibling( 0 );
child->setNextSibling( 0 );
--- khtml/rendering/render_object.cpp.orig 2008-05-03 09:22:40.000000000 +0200
+++ khtml/rendering/render_object.cpp 2008-05-03 09:22:47.000000000 +0200
@@ -178,7 +178,8 @@
m_isRoot( false ),
m_afterPageBreak( false ),
m_needsPageClear( false ),
- m_containsPageBreak( false )
+ m_containsPageBreak( false ),
+ m_doNotDelete(false)
{
assert( node );
if (node->getDocument()->documentElement() == node) setIsRoot(true);
--- khtml/rendering/render_object.h.orig 2008-05-03 09:22:04.000000000 +0200
+++ khtml/rendering/render_object.h 2008-05-03 09:22:47.000000000 +0200
@@ -754,6 +754,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();
}
@@ -835,7 +838,9 @@
bool m_needsPageClear : 1;
bool m_containsPageBreak : 1;
- // ### we have 16 + 24 bits. Cut 8 and save 32
+ bool m_doNotDelete : 1; // This object should not be auto-deleted
+
+ // ### we have 16 + 27 bits.
void arenaDelete(RenderArena *arena, void *objectBase);