From 05f43cd6ba5448e9ce9e8a02943305ec2c86f80a Mon Sep 17 00:00:00 2001
From: Marco Bubke <marco.bubke@nokia.com>
Date: Tue, 13 Apr 2010 16:15:13 +0200
Subject: [PATCH] Fix crash for double deleted items

Reviewed-by: kkoehne
---
 .../components/formeditor/formeditorscene.cpp            | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp
index 46ade624dc8..ba2896d8ceb 100644
--- a/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp
@@ -368,7 +368,14 @@ void FormEditorScene::setPaintMode(PaintMode paintMode)
 
 void FormEditorScene::clearFormEditorItems()
 {
-    foreach (QGraphicsItem *item, items()) {
+    QList<QGraphicsItem*> itemList(items());
+
+    foreach (QGraphicsItem *item, itemList) {
+        if (qgraphicsitem_cast<FormEditorItem* >(item))
+            item->setParentItem(0);
+    }
+
+    foreach (QGraphicsItem *item, itemList) {
         if (qgraphicsitem_cast<FormEditorItem* >(item))
             delete item;
     }
-- 
GitLab