summaryrefslogtreecommitdiff
path: root/tests/auto/qml/qqmlecmascript/testtypes.h
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2023-05-09 16:59:24 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2023-05-12 15:06:42 +0200
commit13fc038d8d4baa9e199fbd5a7e4c08650a88172e (patch)
treef0f01ea5594bd3c82a9faa97645c8dbc37b73476 /tests/auto/qml/qqmlecmascript/testtypes.h
parentf3b1d6135222e9ce41845a00831a3eb24cd36449 (diff)
downloadqtdeclarative-13fc038d8d4baa9e199fbd5a7e4c08650a88172e.tar.gz
Fix reset support for value types
Our value type refactoring in 6.5 broke reset support for value types when that write happens through virtualPut. Fix that by checking whether the value we're assinging is undefined before attempting any conversion, and reset the gadget in that case (if it is actually resettable). Task-number: QTBUG-113473 Pick-to: 6.5 Change-Id: Ifaa2d045f718fc3cb2d5e75b3626b41175ac3a3b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/testtypes.h')
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h
index ff9dda36d1..bc4d97237c 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.h
+++ b/tests/auto/qml/qqmlecmascript/testtypes.h
@@ -2000,6 +2000,41 @@ public:
QBindable<int> bindableX() const { return &_xProp; }
};
+class ResettableGadget
+{
+ Q_GADGET
+ Q_PROPERTY(qreal value READ value WRITE setValue RESET resetValue)
+
+ qreal m_value = 0;
+
+public:
+ qreal value() const { return m_value; }
+ void setValue(qreal val) { m_value = val; }
+ void resetValue() { m_value = 42; }
+};
+
+class ResettableGadgetHolder : public QObject {
+ Q_OBJECT
+ QML_ELEMENT
+
+ Q_PROPERTY(ResettableGadget g READ g WRITE setG NOTIFY gChanged)
+ ResettableGadget m_g;
+
+signals:
+ void gChanged();
+
+public:
+ ResettableGadget g() const { return m_g; }
+ void setG(ResettableGadget newG)
+ {
+ if (m_g.value() == newG.value())
+ return;
+ m_g = newG;
+ Q_EMIT gChanged();
+ }
+};
+
+
void registerTypes();
#endif // TESTTYPES_H