diff options
author | Michael Brasser <michael.brasser@live.com> | 2016-10-14 07:52:24 -0500 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2016-11-15 03:50:22 +0000 |
commit | 8ff69297eeddc3f5650c4cc5517c7e2eafaf6c59 (patch) | |
tree | fa98e54704e51cd5e7732aa5491f18856e81a7db /tests/auto/qml/qqmlconnections | |
parent | 291223876bb190ca4b5a07cf8f605c7bf88d7ab6 (diff) |
Setting Connection's target to null should disconnect implicit target
Change-Id: Id7c8c7080e6db8bb6d09c1df13cddaef047cf611
Task-number: QTBUG-56499
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlconnections')
-rw-r--r-- | tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml | 9 | ||||
-rw-r--r-- | tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp | 27 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml b/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml new file mode 100644 index 0000000000..d5aa0f102a --- /dev/null +++ b/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + width: 50 + + property bool tested: false + + Connections { onWidthChanged: tested = true } +} diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp index e529c74acc..eaf08a2a26 100644 --- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp +++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp @@ -56,6 +56,7 @@ private slots: void errors(); void rewriteErrors(); void singletonTypeTarget(); + void clearImplicitTarget(); private: QQmlEngine engine; @@ -329,6 +330,32 @@ void tst_qqmlconnections::singletonTypeTarget() delete object; } +//QTBUG-56499 +void tst_qqmlconnections::clearImplicitTarget() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("test-connection-implicit.qml")); + QQuickItem *item = qobject_cast<QQuickItem*>(c.create()); + + QVERIFY(item != 0); + + // normal case: fire Connections + item->setWidth(100.); + QCOMPARE(item->property("tested").toBool(), true); + + item->setProperty("tested", false); + // clear the implicit target + QQmlConnections *connections = item->findChild<QQmlConnections*>(); + QVERIFY(connections); + connections->setTarget(0); + + // target cleared: no longer fire Connections + item->setWidth(150.); + QCOMPARE(item->property("tested").toBool(), false); + + delete item; +} + QTEST_MAIN(tst_qqmlconnections) #include "tst_qqmlconnections.moc" |