aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypewrapper.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-08-08 12:52:56 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-08 15:35:18 +0200
commit0c179baade8f4a57c0f9fe7b48367412e8a41f2a (patch)
tree30c775eda2fcba23827bdfc7f5d4c042813b8a2e /src/qml/qml/qqmltypewrapper.cpp
parent5046e8898803ab3e83f4dae1260345fdba207a32 (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/qqmltypewrapper.cpp')
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index f4e9d9b406..20c403c95c 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -157,7 +157,7 @@ Value QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
}
// check for property.
- return QV4::QObjectWrapper::getQmlProperty(v4->current, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision);
+ return QV4::QObjectWrapper::getQmlProperty(v4->current, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty);
} else if (!siinfo->scriptApi(e).isUndefined()) {
QV4::ExecutionEngine *engine = QV8Engine::getV4(v8engine);
// NOTE: if used in a binding, changes will not trigger re-evaluation since non-NOTIFYable.
@@ -181,7 +181,7 @@ Value QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
} else if (w->object) {
QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
if (ao)
- return QV4::QObjectWrapper::getQmlProperty(v4->current, context, ao, name, QV4::QObjectWrapper::IgnoreRevision);
+ return QV4::QObjectWrapper::getQmlProperty(v4->current, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty);
// Fall through to base implementation
}
@@ -193,8 +193,7 @@ Value QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
} else if (w->typeNamespace) {
Q_ASSERT(w->importNamespace);
- QQmlTypeNameCache::Result r = w->typeNamespace->query(name,
- w->importNamespace);
+ QQmlTypeNameCache::Result r = w->typeNamespace->query(name, w->importNamespace);
if (r.isValid()) {
QQmlContextData *context = v8engine->callingContext();
@@ -260,6 +259,14 @@ void QmlTypeWrapper::put(Managed *m, String *name, const Value &value)
}
}
+PropertyAttributes QmlTypeWrapper::query(const Managed *m, String *name)
+{
+ // ### Implement more efficiently.
+ bool hasProperty = false;
+ const_cast<Managed*>(m)->get(name, &hasProperty);
+ return hasProperty ? Attr_Data : Attr_Invalid;
+}
+
void QmlTypeWrapper::destroy(Managed *that)
{
static_cast<QmlTypeWrapper *>(that)->~QmlTypeWrapper();