2 import Qt.test 1.0 as ModApi
7 property bool success: false
8 property bool c1HasBeenDestroyed: false
10 SignalEmittedComponent {
12 function c1aChangedHandler() {
13 // this should still be called, after c1 has been destroyed by gc,
14 // because the onDestruction handler of c1 will be triggered prior
15 // to when c1 will be invalidated.
16 if (root.c1HasBeenDestroyed)
21 Component.onCompleted: {
22 // dynamically construct sibling. When it goes out of scope, it should be gc'd.
23 // note that the gc() will call weakqobjectcallback which will set queued for
24 // deletion flag -- thus QQmlData::wasDeleted() will return true for that object..
25 var comp = Qt.createComponent("SignalEmittedComponent.qml", root);
26 var c1 = comp.createObject(null); // JS ownership
27 c1.onAChanged.connect(c2.c1aChangedHandler);
28 c1HasBeenDestroyed = true; // gc will collect c1.
29 // return to event loop.
32 function destroyC2() {
33 // we must gc() c1 first, then destroy c2, then handle events.