diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-08-08 12:52:56 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-08 15:35:18 +0200 |
commit | 0c179baade8f4a57c0f9fe7b48367412e8a41f2a (patch) | |
tree | 30c775eda2fcba23827bdfc7f5d4c042813b8a2e /src/qml/qml/qqmlvaluetypewrapper.cpp | |
parent | 5046e8898803ab3e83f4dae1260345fdba207a32 (diff) |
Fix hasOwnProperty on various types wrapped in QML
* Change semantics of Object::query to not walk the prototype chain but let the
caller do that where needed (__hasProperty__)
* Re-implement query in various places
* Implement method_hasOwnProperty to fall back to query() if getOwnProperty failed
* Fix missing prototype initialization in some qml wrappers, as well as missing base
class calls to ::get()
Change-Id: Ic2a702fd5ff3be2ff3c8317a8a24f99940a9594f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlvaluetypewrapper.cpp')
-rw-r--r-- | src/qml/qml/qqmlvaluetypewrapper.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 05412e99a7..64baf8b1ce 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -201,6 +201,25 @@ bool QmlValueTypeWrapper::isEqualTo(Managed *m, Managed *other) return false; } +PropertyAttributes QmlValueTypeWrapper::query(const Managed *m, String *name) +{ + const QmlValueTypeWrapper *r = m->as<const QmlValueTypeWrapper>(); + QV4::ExecutionEngine *v4 = m->engine(); + if (!r) + v4->current->throwTypeError(); + + QQmlPropertyData local; + QQmlPropertyData *result = 0; + { + QQmlData *ddata = QQmlData::get(r->type, false); + if (ddata && ddata->propertyCache) + result = ddata->propertyCache->property(name, 0, 0); + else + result = QQmlPropertyCache::property(r->v8->engine(), r->type, name, 0, local); + } + return result ? Attr_Data : Attr_Invalid; +} + bool QmlValueTypeWrapper::isEqual(const QVariant& value) { if (objectType == QmlValueTypeWrapper::Reference) { |