2 import Qt.test.qobjectApi 1.0 as QObjectApi
5 property bool success: true
6 property Item testProp: null
8 // first we create an object and reference it via a dynamic variant property
9 function createReference() {
10 var c = Qt.createComponent("HRMDPComponent.qml");
11 testProp = c.createObject(null); // QML ownership.
14 // after a gc, it should not have been collected.
15 function ensureReference() {
16 if (testProp == null) success = false; // should not have triggered delete notify / zeroed testProp value
17 if (testProp.variantCanary != 5) success = false; // should not have deleted vmemo of object referenced by testProp
18 if (testProp.varCanary != 12) success = false; // should not have collected vmemo vmeProperties
19 if (QObjectApi.qobjectTestWritableProperty != 42) success = false; // should not have been set to 43.
22 // then we manually delete the item being referenced
23 function manuallyDelete() {
24 QObjectApi.deleteQObject(testProp);
25 if (QObjectApi.qobjectTestWritableProperty != 43) success = false; // should have been set to 43.
28 // after a gc (and deferred deletion process) the object should be gone
29 function ensureDeleted() {
30 // a crash should not have occurred during the previous gc due to the
31 // VMEMO attempting to keep a previously deleted QObject alive.
32 if (testProp != null) success = false; // delete notify should have zeroed testProp value.