diff options
author | Chris Adams <christopher.adams@nokia.com> | 2012-07-19 10:46:35 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-24 04:04:33 +0200 |
commit | cc688cc0cc4f5d4fc8f01411798872205df1d59c (patch) | |
tree | 7258f74e3769f598a0a22609c095a71d0d1c3fc5 /src/qml/qml/qqmlvaluetype_p.h | |
parent | ec0ad9abc684604e7fbb9eb25899e95b58c0f7ad (diff) |
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 <martin.jones@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlvaluetype_p.h')
-rw-r--r-- | src/qml/qml/qqmlvaluetype_p.h | 17 |
1 files changed, 15 insertions, 2 deletions
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: |