aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/data/signalEmitted.3.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/data/signalEmitted.3.qml')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalEmitted.3.qml17
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/signalEmitted.3.qml b/tests/auto/qml/qqmlecmascript/data/signalEmitted.3.qml
index 0cae5c02d8..8a09414478 100644
--- a/tests/auto/qml/qqmlecmascript/data/signalEmitted.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalEmitted.3.qml
@@ -7,16 +7,16 @@ Item {
property bool success: false
property bool c1HasBeenDestroyed: false
- property Item c1 // not a js reference, so won't keep it alive
-
SignalEmittedComponent {
id: c2
- property int c1a: if (root.c1) root.c1.a; else 0; // will change during onDestruction handler of c1.
function c1aChangedHandler() {
// this should still be called, after c1 has been destroyed by gc,
// because the onDestruction handler of c1 will be triggered prior
// to when c1 will be invalidated.
- if (root.c1HasBeenDestroyed && c1a == 20) root.c1.setSuccessPropertyOf(root, true);
+ if (root.c1HasBeenDestroyed)
+ root.success = true;
+ // note: cannot call c1::setSuccessPropertyOf(root, true), since any
+ // reference to c1 would have kept c1 alive. So, set it directly.
}
}
@@ -24,11 +24,10 @@ Item {
// dynamically construct sibling. When it goes out of scope, it should be gc'd.
// note that the gc() will call weakqobjectcallback which will set queued for
// deletion flag -- thus QQmlData::wasDeleted() will return true for that object..
- var c = Qt.createComponent("SignalEmittedComponent.qml", root);
- var o = c.createObject(null); // JS ownership
- o.onAChanged.connect(c2.c1aChangedHandler);
- c1 = o;
- c1HasBeenDestroyed = true;
+ var comp = Qt.createComponent("SignalEmittedComponent.qml", root);
+ var c1 = comp.createObject(null); // JS ownership
+ c1.onAChanged.connect(c2.c1aChangedHandler);
+ c1HasBeenDestroyed = true; // gc will collect c1.
// return to event loop.
}
}