aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcomponent/data
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-04-27 16:12:09 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-04 03:41:33 +0200
commitc31026c9ca7ff0c745dba577f9ac2c14d1ef68c5 (patch)
treedd3150dd95af2fa9759852d61d9c87b86322852a /tests/auto/qml/qqmlcomponent/data
parent6318560eca7e3247a63620ce24d2d7e291dd5d84 (diff)
Emit Component.onDestruction before context is invalidated
When a component no longer has any live references, emit the destruction signal immediately so that handlers are run before the associated V8 resources are invalidated. Also, when the root context of the engine is destroyed, emit the destruction signal before destroying any resources needed to process the resulting binding invocations. Change-Id: I722dd6e4b60c499b533fc45e33b61e95bca6187f Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlcomponent/data')
-rw-r--r--tests/auto/qml/qqmlcomponent/data/onDestructionCount.qml16
-rw-r--r--tests/auto/qml/qqmlcomponent/data/onDestructionLookup.qml25
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlcomponent/data/onDestructionCount.qml b/tests/auto/qml/qqmlcomponent/data/onDestructionCount.qml
new file mode 100644
index 0000000000..3938acf6a5
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/data/onDestructionCount.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.0
+
+Item {
+ Component {
+ id: internalComponent
+
+ Item {
+ Component.onDestruction: console.warn('Component.onDestruction')
+ }
+ }
+
+ Component.onCompleted: {
+ internalComponent.createObject()
+ gc()
+ }
+}
diff --git a/tests/auto/qml/qqmlcomponent/data/onDestructionLookup.qml b/tests/auto/qml/qqmlcomponent/data/onDestructionLookup.qml
new file mode 100644
index 0000000000..a49a86e1f3
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/data/onDestructionLookup.qml
@@ -0,0 +1,25 @@
+import QtQuick 2.0
+
+Item {
+ id: root
+
+ property bool success: false
+
+ Component {
+ id: internalComponent
+
+ Item {
+ id: internalRoot
+
+ property string foo: ''
+
+ Component.onCompleted: { internalRoot.foo = 'bar' }
+ Component.onDestruction: { root.success = (internalRoot.foo == 'bar') }
+ }
+ }
+
+ Component.onCompleted: {
+ internalComponent.createObject()
+ gc()
+ }
+}