aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/data
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2025-09-30 08:11:48 +0200
committerUlf Hermann <ulf.hermann@qt.io>2025-10-06 13:21:01 +0200
commit8203f860d1ba2c61de28dbae5f34db6601e02214 (patch)
treecf56da643caf8630cb651063458fcf06c2c17164 /tests/auto/qml/qmlcppcodegen/data
parent5d29d63e77af7129e67c5bce6dfddaf5cf266ed0 (diff)
QtQml: Add test for writing to delayed properties
This proves that commit a7349e6433d092398d76cafa5408753f06892cd7 fixes QTBUG-139687. Pick-to: 6.10 6.8 Fixes: QTBUG-139687 Change-Id: I2730b545738bf75e381b0b396b74c5060fa9b0e1 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/data')
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/refuseWrite.h64
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/writeBackReferenceObject.qml47
3 files changed, 113 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
index e6be35caf4..ce3767a2b1 100644
--- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
+++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
@@ -27,6 +27,7 @@ set(cpp_sources
objectwithmethod.h
person.cpp person.h
qmlusing.h
+ refuseWrite.h
resettable.h
scriptstringholder.h
sequenceToIterable.h
@@ -347,6 +348,7 @@ set(qml_files
versionmismatch.qml
voidConversion.qml
voidfunction.qml
+ writeBackReferenceObject.qml
writeback.qml
dummy_imports.qml
)
diff --git a/tests/auto/qml/qmlcppcodegen/data/refuseWrite.h b/tests/auto/qml/qmlcppcodegen/data/refuseWrite.h
new file mode 100644
index 0000000000..779eb1cc17
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/refuseWrite.h
@@ -0,0 +1,64 @@
+// Copyright (C) 2025 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef REFUSEWRITE_H
+#define REFUSEWRITE_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qqueue.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qcoreevent.h>
+#include <QtQmlIntegration/qqmlintegration.h>
+
+class RefuseWrite : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ Q_PROPERTY(QVariantList things READ things WRITE setThings NOTIFY thingsChanged)
+
+public:
+ RefuseWrite(QObject *parent = nullptr) : QObject(parent) {
+ m_things.enqueue(QVariantList());
+ }
+
+ QVariantList things() const
+ {
+ return m_things.head();
+ }
+
+ void setThings(const QVariantList &newThings)
+ {
+ m_things.enqueue(newThings);
+ startTimer(1);
+ }
+
+ qsizetype pendingChanges() const
+ {
+ return m_things.size() - 1;
+ }
+
+private:
+ void timerEvent(QTimerEvent *event) override
+ {
+ if (m_things.size() < 2) {
+ killTimer(event->id());
+ return;
+ }
+
+ const QVariantList old = m_things.dequeue();
+ if (old != m_things.head())
+ emit thingsChanged();
+ }
+
+signals:
+ void thingsChanged();
+
+private:
+ QQueue<QVariantList> m_things;
+};
+
+#endif // REFUSEWRITE_H
+
+
+
+
diff --git a/tests/auto/qml/qmlcppcodegen/data/writeBackReferenceObject.qml b/tests/auto/qml/qmlcppcodegen/data/writeBackReferenceObject.qml
new file mode 100644
index 0000000000..a92ff17408
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/writeBackReferenceObject.qml
@@ -0,0 +1,47 @@
+pragma Strict
+import QtQml
+
+RefuseWrite {
+ id: self
+ function idToId() {
+ let v = self.things
+ v[1] = 42.25
+ self.things = v
+ }
+
+ function scopeToScope() {
+ let v = things
+ v[0] = 0.5
+ things = v
+ }
+
+ function idToScope() {
+ let v = self.things
+ v[2] = 3
+ self.things = v
+ }
+
+ function scopeToId() {
+ let v = things
+ v[3] = 4
+ things = v
+ }
+
+ function scopeToUnrelated() {
+ let v = things
+ v[4] = 5
+ a.things = v
+ }
+
+ function idToUnrelated() {
+ let v = self.things
+ v[5] = 6
+ a.things = v
+ }
+
+ property QtObject a: QtObject {
+ id: a
+ property list<var> things
+ }
+}
+