aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qqmlbinding/data/deleteStashedObject.qml51
-rw-r--r--tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp19
2 files changed, 70 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlbinding/data/deleteStashedObject.qml b/tests/auto/qml/qqmlbinding/data/deleteStashedObject.qml
new file mode 100644
index 0000000000..fb95305791
--- /dev/null
+++ b/tests/auto/qml/qqmlbinding/data/deleteStashedObject.qml
@@ -0,0 +1,51 @@
+pragma ComponentBehavior: Bound
+import QtQml
+
+QtObject {
+ id: root
+
+ property Component c: Component {
+ QtObject {
+ Component.onDestruction: {
+ console.log("dead")
+ timer.start()
+ }
+ }
+ }
+
+ property QtObject stashed: c.createObject()
+ property QtObject replacement: QtObject {}
+
+ onStashedChanged: {
+ if (stashed) {
+ page = stashed
+ console.log("alive")
+ binding.when = true
+ }
+ }
+
+ property QtObject page
+
+ property Binding binding: Binding {
+ id: binding
+ target: root
+ property: "page"
+ when: false
+ value: root.replacement
+ }
+
+ property Timer timer: Timer {
+ id: timer
+ interval: 10
+ onTriggered: {
+ console.log("before")
+ binding.when = false
+ console.log("after")
+ }
+ }
+
+ Component.onCompleted: {
+ console.log("destroy")
+ stashed.destroy();
+ }
+}
diff --git a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
index 42f5cfc1dc..48f437387d 100644
--- a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
+++ b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
@@ -53,6 +53,7 @@ private slots:
void qQmlPropertyToPropertyBinding();
void qQmlPropertyToPropertyBindingReverse();
void delayedBindingDestruction();
+ void deleteStashedObject();
private:
QQmlEngine engine;
@@ -856,6 +857,24 @@ void tst_qqmlbinding::delayedBindingDestruction()
verifyDelegate(QLatin1String("foo"));
}
+void tst_qqmlbinding::deleteStashedObject()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("deleteStashedObject.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+
+ QTest::ignoreMessage(QtDebugMsg, "alive");
+ QTest::ignoreMessage(QtDebugMsg, "destroy");
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object);
+ QVERIFY(object->property("page").value<QObject *>() != nullptr);
+
+ QTest::ignoreMessage(QtDebugMsg, "dead");
+ QTest::ignoreMessage(QtDebugMsg, "before");
+ QTest::ignoreMessage(QtDebugMsg, "after");
+ QTRY_VERIFY(object->property("page").value<QObject *>() == nullptr);
+}
+
QTEST_MAIN(tst_qqmlbinding)
#include "tst_qqmlbinding.moc"