[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/koffice/2.0/koffice/libs/flake
From: Thomas Zander <zander () kde ! org>
Date: 2009-04-15 19:32:57
Message-ID: 1239823977.173336.4118.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 954447 by zander:
Fixes: setting a shape parent to zero didn't always remove it from the parent
BUG:189558
RevBy: Thorsten Z
Details: The code to avoid recursing deletion was missing one usecase of when the
parent was set to zero. Added test and fixed it in a better way.
M +6 -5 KoShape.cpp
M +12 -0 tests/TestShapeContainer.cpp
M +1 -1 tests/TestShapeContainer.h
--- branches/koffice/2.0/koffice/libs/flake/KoShape.cpp #954446:954447
@@ -387,13 +387,14 @@
{
if (d->parent == parent)
return;
- if (parent && dynamic_cast<KoShape*>(parent) != this) {
- if (d->parent)
- d->parent->removeChild(this);
+ KoShapeContainer *oldParent = d->parent;
+ d->parent = 0; // avoids recursive removing
+ if (oldParent)
+ oldParent->removeChild(this);
+ if (parent && parent != this) {
d->parent = parent;
parent->addChild(this);
- } else
- d->parent = 0;
+ }
notifyChanged();
d->shapeChanged(ParentChanged);
}
--- branches/koffice/2.0/koffice/libs/flake/tests/TestShapeContainer.cpp #954446:954447
@@ -63,5 +63,17 @@
QCOMPARE(shape.parent(), &container2);
}
+void TestShapeContainer::testSetParent2()
+{
+ MockContainerModel *model = new MockContainerModel();
+ MockContainer container(model);
+ MockShape *shape = new MockShape();
+ shape->setParent(&container);
+ QCOMPARE(model->iterator().count(), 1);
+
+ shape->setParent(0);
+ QCOMPARE(model->iterator().count(), 0);
+}
+
QTEST_MAIN(TestShapeContainer)
#include "TestShapeContainer.moc"
--- branches/koffice/2.0/koffice/libs/flake/tests/TestShapeContainer.h #954446:954447
@@ -10,7 +10,7 @@
// tests
void testModel();
void testSetParent();
-
+ void testSetParent2();
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic