aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.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/handleReferenceManagement.dynprop.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/handleReferenceManagement.dynprop.qml')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.qml31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.qml
new file mode 100644
index 0000000000..30dd4bcaea
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.qml
@@ -0,0 +1,31 @@
+import QtQuick 2.0
+import Qt.test.qobjectApi 1.0 as QObjectApi
+
+Item {
+ property bool success: true
+ property variant testProp: null
+
+ // first we create an object and reference it via a dynamic variant property
+ function createReference() {
+ var c = Qt.createComponent("HRMDPComponent.qml");
+ testProp = c.createObject(null); // QML ownership.
+ }
+
+ // after a gc, it should not have been collected.
+ function ensureReference() {
+ if (testProp == null) success = false; // should not have triggered delete notify / zeroed testProp value
+ if (testProp.variantCanary != 5) success = false; // should not have deleted vmemo of object referenced by testProp
+ if (testProp.varCanary != 12) success = false; // should not have collected vmemo vmeProperties
+ if (QObjectApi.qobjectTestWritableProperty != 42) success = false; // should not have been set to 43.
+ }
+
+ // then we remove the reference.
+ function removeReference() {
+ testProp = null; // allow original object to be released.
+ }
+
+ // after a gc (and deferred deletion process) the object should be gone
+ function ensureDeletion() {
+ if (QObjectApi.qobjectTestWritableProperty != 43) success = false; // should have been set to 43.
+ }
+}