aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcontext/data
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-04-27 16:09:22 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-01 06:04:47 +0200
commite39908c658c6caa2013bc7356eb904b669af1bfb (patch)
tree34c2cf6f42ce9d8f0ce43f940e5da0dc8f52879e /tests/auto/qml/qqmlcontext/data
parent78f1d2679242c84efe6d8eb763c13caf58efe19d (diff)
Ensure context is valid before VME method creation
Ensure that a valid context exists prior to evaluation of a VME method function. Invalid contexts can occur if a method's first invocation is triggered after the destruction of the component's context. Task-number: QTBUG-25516 Change-Id: I349a73c5713e178f920c44f5ddcaa1dc6eec199f Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlcontext/data')
-rw-r--r--tests/auto/qml/qqmlcontext/data/ContainerComponent.qml5
-rw-r--r--tests/auto/qml/qqmlcontext/data/ContentComponent.qml10
-rw-r--r--tests/auto/qml/qqmlcontext/data/evalAfterInvalidate.qml14
3 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlcontext/data/ContainerComponent.qml b/tests/auto/qml/qqmlcontext/data/ContainerComponent.qml
new file mode 100644
index 0000000000..ae90c20cf8
--- /dev/null
+++ b/tests/auto/qml/qqmlcontext/data/ContainerComponent.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+Item {
+ function doSomething() { if (333 == 666) console.log('doSomething') }
+}
diff --git a/tests/auto/qml/qqmlcontext/data/ContentComponent.qml b/tests/auto/qml/qqmlcontext/data/ContentComponent.qml
new file mode 100644
index 0000000000..f937b196ed
--- /dev/null
+++ b/tests/auto/qml/qqmlcontext/data/ContentComponent.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.0
+
+Item {
+ property int count: 0
+ property bool hasValidParent: parent && parent.children.length != 0
+
+ onHasValidParentChanged: {
+ if (++count > 1) parent.doSomething()
+ }
+}
diff --git a/tests/auto/qml/qqmlcontext/data/evalAfterInvalidate.qml b/tests/auto/qml/qqmlcontext/data/evalAfterInvalidate.qml
new file mode 100644
index 0000000000..27879c48bf
--- /dev/null
+++ b/tests/auto/qml/qqmlcontext/data/evalAfterInvalidate.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ Component.onCompleted: {
+ var i = containerComponent.createObject(root);
+ contentComponent.createObject(i);
+ i.destroy()
+ }
+
+ property Component containerComponent: ContainerComponent {}
+ property Component contentComponent: ContentComponent {}
+}