diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-04-26 11:05:41 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-30 01:52:57 +0200 |
commit | 0e8af75e877d46cb656d03cf575804f2c17ec33f (patch) | |
tree | 6b3466202d1a62b7c5d7fb5aff904599ee8d3ca5 /src/quick/util/qquickglobal.cpp | |
parent | 1b48bb5602bd90dc78e1ff09207f682f6a43edd2 (diff) |
Ensure external value types are initialized before write
Ensure that the logic used when writing to a property having a value
type provided by an external module matches that used for properties
of internal value types.
Change-Id: I925b8b30a211ef813e2a51134411a162b0b146b5
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'src/quick/util/qquickglobal.cpp')
-rw-r--r-- | src/quick/util/qquickglobal.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp index b99cb7a1d4..6869d480d5 100644 --- a/src/quick/util/qquickglobal.cpp +++ b/src/quick/util/qquickglobal.cpp @@ -178,6 +178,13 @@ private: }; +// Note: The functions in this class provide handling only for the types +// that the QML engine will currently actually call them for, so many +// appear incompletely implemented. For some functions, the implementation +// would be obvious, but for others (particularly create and createFromString) +// the exact semantics are unknown. For this reason unused functionality +// has been omitted. + class QQuickValueTypeProvider : public QQmlValueTypeProvider { public: @@ -404,6 +411,26 @@ public: return false; } + template<typename T> + bool typedEqual(const void *lhs, const void *rhs) + { + return (*(reinterpret_cast<const T *>(lhs)) == *(reinterpret_cast<const T *>(rhs))); + } + + bool equal(int type, const void *lhs, const void *rhs) + { + switch (type) { + case QMetaType::QColor: + return typedEqual<QColor>(lhs, rhs); + case QMetaType::QVector3D: + return typedEqual<QVector3D>(lhs, rhs); + case QMetaType::QVector4D: + return typedEqual<QVector4D>(lhs, rhs); + } + + return false; + } + bool store(int type, const void *src, void *dst, size_t n) { switch (type) { |