Bug#476896: kdelibs4c2a: Ported patch
Package: kdelibs4c2a
Followup-For: Bug #476896
There are two trivial conflicts when applying upstream's patch to the
Debian package. In case it saves some time, I prepared a patch
with the conflicts resolved.
commit 3b2e06674197b23e52381521185bd13e046a16d7
Author: Ted Percival <ted@midg3t.net>
Date: Sun Apr 20 12:49:31 2008 +1000
Backported fix for KDE bug #150006
Using attachment #23875
diff --git a/khtml/rendering/render_container.cpp b/khtml/rendering/render_container.cpp
index 7500780..c309b67 100644
--- a/khtml/rendering/render_container.cpp
+++ b/khtml/rendering/render_container.cpp
@@ -79,6 +79,8 @@ void RenderContainer::addChild(RenderObject *newChild, RenderObject *beforeChild
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 @@ void RenderContainer::addChild(RenderObject *newChild, RenderObject *beforeChild
static_cast<RenderText*>(newChild)->setText(textToTransform, true);
}
newChild->attach();
+
+ setDoNotDelete(false);
}
RenderObject* RenderContainer::removeChildNode(RenderObject* oldChild)
@@ -545,7 +549,7 @@ void RenderContainer::removeLeftoverAnonymousBoxes()
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 @@ void RenderContainer::removeLeftoverAnonymousBoxes()
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 );
diff --git a/khtml/rendering/render_object.cpp b/khtml/rendering/render_object.cpp
index 9840688..9f97922 100644
--- a/khtml/rendering/render_object.cpp
+++ b/khtml/rendering/render_object.cpp
@@ -178,7 +178,8 @@ RenderObject::RenderObject(DOM::NodeImpl* node)
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);
diff --git a/khtml/rendering/render_object.h b/khtml/rendering/render_object.h
index 0df080f..ea3938f 100644
--- a/khtml/rendering/render_object.h
+++ b/khtml/rendering/render_object.h
@@ -753,6 +753,9 @@ public:
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 @@ private:
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 + 25 bits.
void arenaDelete(RenderArena *arena, void *objectBase);
Reply to: