aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@digia.com>2014-08-22 09:52:59 +0200
committerMitch Curtis <mitch.curtis@digia.com>2014-08-25 14:41:34 +0200
commit99fd3a6b22a7eabf2aff656a942b0b7e32093254 (patch)
tree42dfa3ea9d15a65b14dece777a4f9d0f20a97c2a
parent916ced089f37d96ca8ef1cdb938791247bd44b72 (diff)
Remove references transforms have to items in QQuickItem's destructor.
In case they try to remove themselves from our list of transforms when that list has already been destroyed after ~QQuickItem() has run. Task-number: QTBUG-40877 Change-Id: Ie57f5dd1e8b791846f08629183974c771553c4bf Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Alan Alpert <aalpert@blackberry.com>
-rw-r--r--src/quick/items/qquickitem.cpp11
-rw-r--r--tests/auto/quick/qquickitem/data/objectChildTransform.qml31
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp13
3 files changed, 55 insertions, 0 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 7b031f3b5b..a6c83fbd34 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -2161,6 +2161,17 @@ QQuickItem::~QQuickItem()
d->changeListeners.clear();
+ /*
+ Remove any references our transforms have to us, in case they try to
+ remove themselves from our list of transforms when that list has already
+ been destroyed after ~QQuickItem() has run.
+ */
+ for (int ii = 0; ii < d->transforms.count(); ++ii) {
+ QQuickTransform *t = d->transforms.at(ii);
+ QQuickTransformPrivate *tp = QQuickTransformPrivate::get(t);
+ tp->items.removeOne(this);
+ }
+
if (d->extra.isAllocated()) {
delete d->extra->contents; d->extra->contents = 0;
delete d->extra->layer; d->extra->layer = 0;
diff --git a/tests/auto/quick/qquickitem/data/objectChildTransform.qml b/tests/auto/quick/qquickitem/data/objectChildTransform.qml
new file mode 100644
index 0000000000..fecb9ac921
--- /dev/null
+++ b/tests/auto/quick/qquickitem/data/objectChildTransform.qml
@@ -0,0 +1,31 @@
+import QtQuick 2.3
+
+Rectangle {
+ width: 360
+ height: 360
+
+ property alias loaderSource: loader.source
+
+ Component {
+ id: crashComponent
+
+ Item {
+ Image {
+ transform: scale
+ }
+
+ Scale {
+ id: scale
+ xScale: 1
+ yScale: 1
+ }
+ }
+ }
+
+ Loader {
+ id: loader
+ anchors.fill: parent
+ sourceComponent: crashComponent
+ }
+}
+
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index a689887977..38dc8e0ac4 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -167,6 +167,8 @@ private slots:
void testSGInitializeAndInvalidate();
+ void objectChildTransform();
+
private:
enum PaintOrderOp {
@@ -1906,7 +1908,18 @@ void tst_qquickitem::testSGInitializeAndInvalidate()
delete view.take();
QCOMPARE(invalidateSpy.size(), expected);
}
+}
+
+void tst_qquickitem::objectChildTransform()
+{
+ QQuickView view;
+ view.setSource(testFileUrl("objectChildTransform.qml"));
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(view.rootObject());
+ QVERIFY(root);
+ root->setProperty("source", QString());
+ // Shouldn't crash.
}
QTEST_MAIN(tst_qquickitem)