aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlproperty/data
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-06-16 11:33:30 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-06-16 23:43:13 +0200
commit46842ec7c67ce16ade08076c0fd7e78e96f33887 (patch)
tree8820dfcfc3cb750993678d947c26e013b1fc7519 /tests/auto/qml/qqmlproperty/data
parent74fac24a2785af1fe7a3252b1c804c762ede400b (diff)
QML: Guard QProperty change triggers against deletion of target
Previously, we relied on QObject* pointers being unique even after deletion of the objects. That's not good. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-114329 Change-Id: Ia0a2c1d2cb5d8a0d47ec00e73424c959c59c09bc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlproperty/data')
-rw-r--r--tests/auto/qml/qqmlproperty/data/invalidateQPropertyChangeTriggers.qml50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlproperty/data/invalidateQPropertyChangeTriggers.qml b/tests/auto/qml/qqmlproperty/data/invalidateQPropertyChangeTriggers.qml
new file mode 100644
index 0000000000..bfa832c1c8
--- /dev/null
+++ b/tests/auto/qml/qqmlproperty/data/invalidateQPropertyChangeTriggers.qml
@@ -0,0 +1,50 @@
+import QtQml
+
+QtObject {
+ id: root
+ objectName: column.text
+
+ property Component c: Component {
+ id: comp
+ QtObject { }
+ }
+
+ property QtObject rectItem: null
+
+ property bool running: false
+
+ property Timer t: Timer {
+ id: column
+ interval: 200
+ running: root.running
+ repeat: true
+
+ property string text: {
+ let item = root.rectItem
+ let result = rectItem ? rectItem.objectName : "Create Object"
+ return result
+ }
+
+ onTriggered: {
+ let rectItem = root.rectItem
+
+ // If rectItem exists destory it.
+ if (rectItem) {
+ rectItem.destroy()
+ return
+ }
+
+ // Otherwise create a new object
+ let newRectItem = comp.createObject(column, {})
+
+
+ // Setting the objectName before setting root.rectItem seems to work.
+ // newRectItem.width = 1200
+ root.rectItem = newRectItem
+
+ // But setting the objectName after setting root.rectItem seems to
+ // cause the issue.
+ newRectItem.objectName = "1300"
+ }
+ }
+}