aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/data/signalEmitted.3.qml
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2012-03-14 12:00:40 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-30 04:37:59 +0200
commit47eb68ab0b8d9ffd357cbad2f74b63ee2cf00dad (patch)
tree5159737869c7b8981003ed519b8cd8541799728e /tests/auto/qml/qqmlecmascript/data/signalEmitted.3.qml
parent7f8c243dec987018db47547c6ddea9cd8272e02a (diff)
Ensure that variant property references keep QObjects alive
Previously, only var property references could keep QObjects alive. This meant that the garbage collector would collect QObject data prematurely. This commit ensures that variant properties keep QObjects alive as required. Task-number: QTBUG-24767 Change-Id: Ic98a06863251a3e7d6384ba9256810a78fb23406 Reviewed-by: Martin Jones <martin.jones@nokia.com>
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.
}
}