From cc688cc0cc4f5d4fc8f01411798872205df1d59c Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Thu, 19 Jul 2012 10:46:35 +1000 Subject: Fix value-type semantics in variant properties Previously, variant properties storing value-type values would be treated as value-type-copy values rather than value-type-reference values. This caused inconsistency in behaviour with value-type subproperty assignment. Task-number: QTBUG-26562 Change-Id: I524ee06ab8e02bf9582c1a88f3317278199225e0 Reviewed-by: Martin Jones --- src/qml/qml/qqmlvaluetype_p.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/qml/qml/qqmlvaluetype_p.h') diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h index 02be333037..153037b248 100644 --- a/src/qml/qml/qqmlvaluetype_p.h +++ b/src/qml/qml/qqmlvaluetype_p.h @@ -71,7 +71,9 @@ class Q_QML_PRIVATE_EXPORT QQmlValueType : public QObject public: QQmlValueType(int userType, QObject *parent = 0); virtual void read(QObject *, int) = 0; + virtual void readVariantValue(QObject *, int, QVariant *) = 0; virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags flags) = 0; + virtual void writeVariantValue(QObject *, int, QQmlPropertyPrivate::WriteFlags, QVariant *) = 0; virtual QVariant value() = 0; virtual void setValue(const QVariant &) = 0; @@ -120,14 +122,25 @@ public: readProperty(obj, idx, &v); } + virtual void readVariantValue(QObject *obj, int idx, QVariant *into) + { + // important: must not change the userType of the variant + readProperty(obj, idx, into); + } + virtual void write(QObject *obj, int idx, QQmlPropertyPrivate::WriteFlags flags) { writeProperty(obj, idx, flags, &v); } + virtual void writeVariantValue(QObject *obj, int idx, QQmlPropertyPrivate::WriteFlags flags, QVariant *from) + { + writeProperty(obj, idx, flags, from); + } + virtual QVariant value() { - return QVariant(v); + return QVariant::fromValue(v); } virtual void setValue(const QVariant &value) @@ -138,7 +151,7 @@ public: virtual bool isEqual(const QVariant &other) const { - return QVariant(v) == other; + return QVariant::fromValue(v) == other; } protected: -- cgit v1.2.3