summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativelanguage/data
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-04-15 06:35:51 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-04-15 06:35:51 (GMT)
commit30a3e78a12b72ab6f67992ec2f06cd4f21a01a6c (patch)
treebb480e0a908016f24a4e57755b2265ebf5b5ea16 /tests/auto/declarative/qdeclarativelanguage/data
parent6362d17d5551749618f5975e050c54fca31c408f (diff)
downloadQt-30a3e78a12b72ab6f67992ec2f06cd4f21a01a6c.zip
Qt-30a3e78a12b72ab6f67992ec2f06cd4f21a01a6c.tar.gz
Qt-30a3e78a12b72ab6f67992ec2f06cd4f21a01a6c.tar.bz2
Add Component.onDestruction attached property
This property complements Component.onCompleted. It is emitted before the destruction actually begins (for the most part) so the objects are still alive and accessible. The QtObject.onDestroyed signal is now blocked as it never really worked properly anyway.
Diffstat (limited to 'tests/auto/declarative/qdeclarativelanguage/data')
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml8
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml17
4 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml b/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml
new file mode 100644
index 0000000..e5a7cf8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+import Qt 4.6
+
+MyQmlObject {
+ property int a: Math.max(10, 9)
+ property int b: 11
+ Component.onDestruction: console.log("Destruction " + a + " " + b);
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt
new file mode 100644
index 0000000..3348494
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt
@@ -0,0 +1 @@
+4:5:Cannot assign to non-existent property "onDestroyed"
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml
new file mode 100644
index 0000000..4eab50a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+
+QtObject {
+ onDestroyed: print("Hello World!")
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml b/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml
new file mode 100644
index 0000000..7ebae7b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml
@@ -0,0 +1,17 @@
+import Test 1.0
+import Qt 4.6
+
+MyTypeObject {
+ // We set a and b to ensure that onCompleted is executed after bindings and
+ // constants have been assigned
+ property int a: Math.min(6, 7)
+ Component.onDestruction: console.log("Destruction " + a + " " + nestedObject.b)
+
+ objectProperty: OnDestructionType {
+ qmlobjectProperty: MyQmlObject {
+ id: nestedObject
+ property int b: 10
+ Component.onDestruction: console.log("Destruction " + a + " " + nestedObject.b)
+ }
+ }
+}