diff options
author | J-P Nurmi <jpnurmi@gmail.com> | 2009-10-20 15:03:10 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-11-03 08:34:52 (GMT) |
commit | e7a10b00be3e4aa197900ecf424e6d44b07248ae (patch) | |
tree | 0dfd8694cb81a7a9e22fcbb339cb2e7fe08a0ef5 /tests/auto/qgraphicsscene | |
parent | 11dea4a8b227801c110f791f350632bf6f0c958d (diff) | |
download | Qt-e7a10b00be3e4aa197900ecf424e6d44b07248ae.zip Qt-e7a10b00be3e4aa197900ecf424e6d44b07248ae.tar.gz Qt-e7a10b00be3e4aa197900ecf424e6d44b07248ae.tar.bz2 |
Fixed QGraphicsScene::clear() not to crash if related top level items
happen to delete each others.
Merge-Request: 1863
Reviewed-by: Andreas
Reviewed-by: Olivier
Diffstat (limited to 'tests/auto/qgraphicsscene')
-rw-r--r-- | tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 0589994..4f76ddd 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -1453,6 +1453,13 @@ void tst_QGraphicsScene::focusItemLostFocus() item->clearFocus(); } +class ClearTestItem : public QGraphicsRectItem +{ +public: + ~ClearTestItem() { qDeleteAll(items); } + QList<QGraphicsItem *> items; +}; + void tst_QGraphicsScene::clear() { QGraphicsScene scene; @@ -1463,6 +1470,19 @@ void tst_QGraphicsScene::clear() scene.clear(); QVERIFY(scene.items().isEmpty()); QCOMPARE(scene.sceneRect(), QRectF(0, 0, 100, 100)); + + ClearTestItem *firstItem = new ClearTestItem; + QGraphicsItem *secondItem = new QGraphicsRectItem; + firstItem->items += secondItem; + + scene.setItemIndexMethod(QGraphicsScene::NoIndex); + scene.addItem(firstItem); + scene.addItem(secondItem); + QCOMPARE(scene.items().at(0), firstItem); + QCOMPARE(scene.items().at(1), secondItem); + // must not crash even if firstItem deletes secondItem + scene.clear(); + QVERIFY(scene.items().isEmpty()); } void tst_QGraphicsScene::setFocusItem() |