Use V4 binding for non-final properties where possible
[profile/ivi/qtdeclarative.git] / tests / auto / qml / qqmlecmascript / data / handleReferenceManagement.dynprop.qml
1 import QtQuick 2.0
2 import Qt.test.qobjectApi 1.0 as QObjectApi
3
4 Item {
5     property bool success: true
6     property variant testProp: null
7
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.
12     }
13
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.
20     }
21
22     // then we remove the reference.
23     function removeReference() {
24         testProp = null; // allow original object to be released.
25     }
26
27     // after a gc (and deferred deletion process) the object should be gone
28     function ensureDeletion() {
29         if (QObjectApi.qobjectTestWritableProperty != 43) success = false; // should have been set to 43.
30     }
31 }