diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-07-18 10:16:12 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-20 05:35:13 +0200 |
commit | fa3dcc0efb2696612bf9db54a7ed4e26a2cf4765 (patch) | |
tree | 1a571292334edd0ea10fda559b8c84862a51b58b /tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml | |
parent | 9018c236c73884ea706ac1d04a306467454e6243 (diff) |
Update var property to null on object deletion
When a var property contains a pointer to a QObject-derived instance,
ensure that object deletion causes the property to be updated.
Task-number: QTBUG-26542
Change-Id: I67a59ffd7f09063328d45dc84889add55a5428e4
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml')
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml new file mode 100644 index 0000000000..ed0e0d10f0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml @@ -0,0 +1,37 @@ +import QtQuick 2.0 + +Item { + property bool success: false + + Component { + id: internal + + Item { + } + } + + property bool expectNull: null + + function setExpectNull(b) { + success = false; + expectNull = b; + } + + property variant obj: null + onObjChanged: success = (expectNull ? obj == null : obj != null) + + Component.onCompleted: { + setExpectNull(false) + obj = internal.createObject(null, {}) + if (!success) return + + // Replace with a different object + setExpectNull(false) + obj = internal.createObject(null, {}) + } + + function destroyObject() { + setExpectNull(true) + obj.destroy(); + } +} |