From bb0d20406d5d1b473b9f8d9c1284d310405fcd47 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 28 Sep 2010 13:55:04 +1000 Subject: Fix crash when trying to append a null transform to QDeclarativeItem. Task-number: QTBUG-13893 (cherry picked from commit 085a121cb1ebba38d62c924500dbc71806b29b3c) --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 2 +- .../declarative/qdeclarativeitem/data/transformCrash.qml | 13 +++++++++++++ .../declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp | 12 ++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/qdeclarativeitem/data/transformCrash.qml diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index e9da4f7..230169d 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1705,7 +1705,7 @@ int QDeclarativeItemPrivate::transform_count(QDeclarativeListProperty *list, QGraphicsTransform *item) { QGraphicsObject *object = qobject_cast(list->object); - if (object) // QGraphicsItem applies the list in the wrong order, so we prepend. + if (object && item) // QGraphicsItem applies the list in the wrong order, so we prepend. QGraphicsItemPrivate::get(object)->prependGraphicsTransform(item); } diff --git a/tests/auto/declarative/qdeclarativeitem/data/transformCrash.qml b/tests/auto/declarative/qdeclarativeitem/data/transformCrash.qml new file mode 100644 index 0000000..ab7fa84 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/transformCrash.qml @@ -0,0 +1,13 @@ +import Qt 4.7 + +Item { + id: wrapper + width: 200 + height: 200 + + QtObject { + id: object + } + + Component.onCompleted: wrapper.transform = object +} diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index 25ca157..6b28c53 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -81,6 +81,8 @@ private slots: void resourcesProperty(); void mouseFocus(); + void transformCrash(); + private: template T *findItem(QGraphicsObject *parent, const QString &objectName); @@ -792,6 +794,16 @@ void tst_QDeclarativeItem::childrenRectBug3() delete canvas; } +// QTBUG-13893 +void tst_QDeclarativeItem::transformCrash() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/transformCrash.qml")); + canvas->show(); + + delete canvas; +} + template T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName) { -- cgit v0.12