summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2010-02-08 11:25:10 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2010-02-08 11:39:19 (GMT)
commit7724c474a941ea3516da6102a16b30ca254afe53 (patch)
tree6e8b751da64bfa25f88b53c732107cbb0d582822
parenta8d09369fea1574b24309d7b7b2bb373021bf387 (diff)
downloadQt-7724c474a941ea3516da6102a16b30ca254afe53.zip
Qt-7724c474a941ea3516da6102a16b30ca254afe53.tar.gz
Qt-7724c474a941ea3516da6102a16b30ca254afe53.tar.bz2
QGraphicsItem: Do not crash at exit if there is static QGraphicsItem.
The DataStore could have been destroyed before. Even if having static QGraphicsItem is not really supported, it is better not to crash Task-number: QTBUG-7629 Reviewed-by: bnilsen
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp3
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index b4e19d1..39c41c4 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1392,7 +1392,8 @@ QGraphicsItem::~QGraphicsItem()
}
delete d_ptr->transformData;
- qt_dataStore()->data.remove(this);
+ if (QGraphicsItemCustomDataStore *dataStore = qt_dataStore())
+ dataStore->data.remove(this);
}
/*!
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 7b54a3b..7c1b97e 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -90,6 +90,8 @@ Q_DECLARE_METATYPE(QRectF)
#define COMPARE_REGIONS QTRY_COMPARE
#endif
+static QGraphicsRectItem staticItem; //QTBUG-7629, we should not crash at exit.
+
static void sendMousePress(QGraphicsScene *scene, const QPointF &point, Qt::MouseButton button = Qt::LeftButton)
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);