summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsscene.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@gmail.com>2009-10-20 15:03:10 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-11-03 08:34:52 (GMT)
commite7a10b00be3e4aa197900ecf424e6d44b07248ae (patch)
tree0dfd8694cb81a7a9e22fcbb339cb2e7fe08a0ef5 /src/gui/graphicsview/qgraphicsscene.cpp
parent11dea4a8b227801c110f791f350632bf6f0c958d (diff)
downloadQt-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 'src/gui/graphicsview/qgraphicsscene.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index a62e486..a4965e4 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -2292,8 +2292,9 @@ void QGraphicsScene::clear()
// NB! We have to clear the index before deleting items; otherwise the
// index might try to access dangling item pointers.
d->index->clear();
- const QList<QGraphicsItem *> items = d->topLevelItems;
- qDeleteAll(items);
+ // NB! QGraphicsScenePrivate::unregisterTopLevelItem() removes items
+ while (!d->topLevelItems.isEmpty())
+ delete d->topLevelItems.first();
Q_ASSERT(d->topLevelItems.isEmpty());
d->lastItemCount = 0;
d->allItemsIgnoreHoverEvents = true;