diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2016-01-27 12:08:18 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2016-01-27 12:17:53 +0000 |
commit | afbfdcff3b3cd14f16736b7c84e04fe9ad61ef8d (patch) | |
tree | 6cc74d05a219e8a687607dbe8d52637955302e52 /src | |
parent | e9a6c1d4e30d6adb2190d52bebb7fecd2b539e82 (diff) |
QML: do not wrap property values of type QVariant.
When reading a propety from a QGadget or a QObject, the values are
stored in a QVariant and later unwrapped/converted to the correct
JavaScript type. However, if the property value is a QVariant, it does
not need to wrap it (again) in a QVariant.
Change-Id: I633d3194f82b6032fc15d9994c4dee5e5609fd21
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlvaluetypewrapper.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 8ddf91ef3c..5486c14c38 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -357,8 +357,14 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha VALUE_TYPE_LOAD(QMetaType::QString, QString, v4->newString); VALUE_TYPE_LOAD(QMetaType::Bool, bool, bool); - QVariant v(result->propType, (void *)0); - void *args[] = { v.data(), 0 }; + QVariant v; + void *args[] = { Q_NULLPTR, Q_NULLPTR }; + if (result->propType == QMetaType::QVariant) { + args[0] = &v; + } else { + v = QVariant(result->propType, static_cast<void *>(Q_NULLPTR)); + args[0] = v.data(); + } metaObject->d.static_metacall(reinterpret_cast<QObject*>(gadget), QMetaObject::ReadProperty, index, args); return v4->fromVariant(v); #undef VALUE_TYPE_ACCESSOR |