diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-01-27 08:43:01 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-01-27 08:46:20 (GMT) |
commit | eb55d07febf858474d8755e31cb554a4b8fabcdc (patch) | |
tree | a1b5bf4f51ed31fc92373698c7f1924b6d0ca4cc | |
parent | 4f124cd0177aa79d17361c3d79669730b6d97adc (diff) | |
download | Qt-eb55d07febf858474d8755e31cb554a4b8fabcdc.zip Qt-eb55d07febf858474d8755e31cb554a4b8fabcdc.tar.gz Qt-eb55d07febf858474d8755e31cb554a4b8fabcdc.tar.bz2 |
Don't crash when appending a null item
Task-number: QTBUG-16871
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 12 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeitem/data/qtbug_16871.qml | 5 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp | 9 |
3 files changed, 21 insertions, 5 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 52e4d79..f463887 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7689,11 +7689,13 @@ void QGraphicsObject::updateMicroFocus() void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item) { - QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object); - if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) { - item->setParentItem(graphicsObject); - } else { - QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0); + if (item) { + QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object); + if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) { + item->setParentItem(graphicsObject); + } else { + QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0); + } } } diff --git a/tests/auto/declarative/qdeclarativeitem/data/qtbug_16871.qml b/tests/auto/declarative/qdeclarativeitem/data/qtbug_16871.qml new file mode 100644 index 0000000..8102df1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/qtbug_16871.qml @@ -0,0 +1,5 @@ +import QtQuick 1.0 + +Item { + children: [ 10 ] +} diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index 447b57b..137522d 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -86,6 +86,7 @@ private slots: void implicitSize(); void testQtQuick11Attributes(); void testQtQuick11Attributes_data(); + void qtbug_16871(); private: template<typename T> @@ -994,6 +995,14 @@ void tst_QDeclarativeItem::testQtQuick11Attributes_data() << ":1 \"Item.onImplicitHeightChanged\" is not available in QtQuick 1.0.\n"; } +void tst_QDeclarativeItem::qtbug_16871() +{ + QDeclarativeComponent component(&engine, SRCDIR "/data/qtbug_16871.qml"); + QObject *o = component.create(); + QVERIFY(o != 0); + delete o; +} + template<typename T> T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName) |