diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-01-07 11:51:37 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2015-01-07 15:34:19 +0100 |
commit | 05fd01c14a7a4b26f366704fb0b0a4eddaceccf4 (patch) | |
tree | 583f404187502c83721db32e901bb8ed108ab51d /src/qml/qml/qqmlvaluetypewrapper.cpp | |
parent | 353e43cb6d73ee97ebff1a8c737b2c133b135ab8 (diff) |
Fix property access and method invocation on value types that use inheritance
For gadgets/value types we use moc's static_metacall, which doesn't call the
parent class implementation. Therefore before placing a static metacall we
must resolve the indicies and find the right meta-object.
Change-Id: I258e3d9ecfc704498c68772dc42b16134a3bfd83
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/qml/qml/qqmlvaluetypewrapper.cpp')
-rw-r--r-- | src/qml/qml/qqmlvaluetypewrapper.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 332cfefde9..85a391fd98 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -307,11 +307,15 @@ ReturnedValue QQmlValueTypeWrapper::get(Managed *m, String *name, bool *hasPrope if (result->propType == metatype) { \ cpptype v; \ void *args[] = { &v, 0 }; \ - metaObject->d.static_metacall(reinterpret_cast<QObject*>(gadget), QMetaObject::ReadProperty, result->coreIndex, args); \ + metaObject->d.static_metacall(reinterpret_cast<QObject*>(gadget), QMetaObject::ReadProperty, index, args); \ return QV4::Encode(constructor(v)); \ } const QMetaObject *metaObject = r->d()->propertyCache->metaObject(); + + int index = result->coreIndex; + QQmlMetaObject::resolveGadgetMethodOrPropertyIndex(QMetaObject::ReadProperty, &metaObject, &index); + void *gadget = r->d()->gadget(); // These four types are the most common used by the value type wrappers @@ -322,9 +326,9 @@ ReturnedValue QQmlValueTypeWrapper::get(Managed *m, String *name, bool *hasPrope QVariant v(result->propType, (void *)0); void *args[] = { v.data(), 0 }; - metaObject->d.static_metacall(reinterpret_cast<QObject*>(gadget), QMetaObject::ReadProperty, result->coreIndex, args); + metaObject->d.static_metacall(reinterpret_cast<QObject*>(gadget), QMetaObject::ReadProperty, index, args); return QV8Engine::fromVariant(v4, v); -#undef VALUE_TYPE_ACCESSOR +#undef VALUE_TYPE_LOAD } void QQmlValueTypeWrapper::put(Managed *m, String *name, const ValueRef value) |