Another property query fix for the QObject bindings
authorSimon Hausmann <simon.hausmann@digia.com>
Mon, 3 Jun 2013 20:25:39 +0000 (22:25 +0200)
committerLars Knoll <lars.knoll@digia.com>
Mon, 3 Jun 2013 20:32:56 +0000 (22:32 +0200)
Include attached properties only for lookups coming through JS, not
when going through the context wrapper. (This doesn't feel quite
right, but preserves behavior right now)

Change-Id: I2fedfd3343614733c8d556f56e604118e19314dc
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/qqmlcontextwrapper.cpp
src/qml/qml/v8/qv8qobjectwrapper.cpp
src/qml/qml/v8/qv8qobjectwrapper_p.h

index f9dc3a3..cdbd6e7 100644 (file)
@@ -231,7 +231,7 @@ Value QmlContextWrapper::get(Managed *m, ExecutionContext *ctx, String *name, bo
         if (scopeObject) {
             if (QV4::QObjectWrapper *o = qobjectWrapper->newQObject(scopeObject)->v4Value().as<QV4::QObjectWrapper>()) {
                 bool hasProp = false;
-                QV4::Value result = o->getProperty(o->engine()->current, propertystring.string().asString(), QV4::QObjectWrapper::CheckRevision, &hasProp);
+                QV4::Value result = o->getQmlProperty(o->engine()->current, propertystring.string().asString(), QV4::QObjectWrapper::CheckRevision, &hasProp);
                 if (hasProp) {
                     if (hasProperty)
                         *hasProperty = true;
index c298728..47a504a 100644 (file)
@@ -119,7 +119,7 @@ void QObjectWrapper::deleteQObject(bool deleteInstantly)
     }
 }
 
-Value QObjectWrapper::getProperty(ExecutionContext *ctx, String *name, QObjectWrapper::RevisionMode revisionMode, bool *hasProperty)
+Value QObjectWrapper::getQmlProperty(ExecutionContext *ctx, String *name, QObjectWrapper::RevisionMode revisionMode, bool *hasProperty, bool includeImports)
 {
     if (QQmlData::wasDeleted(m_object)) {
         if (hasProperty)
@@ -154,7 +154,7 @@ Value QObjectWrapper::getProperty(ExecutionContext *ctx, String *name, QObjectWr
         return result->v4Value();
     }
 
-    if (name->startsWithUpper()) {
+    if (includeImports && name->startsWithUpper()) {
         // Check for attached properties
         if (context && context->imports) {
             QQmlTypeNameCache::Result r = context->imports->query(propertystring);
@@ -178,7 +178,7 @@ Value QObjectWrapper::getProperty(ExecutionContext *ctx, String *name, QObjectWr
 QV4::Value QObjectWrapper::get(Managed *m, ExecutionContext *ctx, String *name, bool *hasProperty)
 {
     QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
-    return that->getProperty(ctx, name, IgnoreRevision, hasProperty);
+    return that->getQmlProperty(ctx, name, IgnoreRevision, hasProperty, /*includeImports*/ true);
 }
 
 void QObjectWrapper::put(Managed *m, ExecutionContext *ctx, String *name, const Value &value)
index c50fd46..4262dd8 100644 (file)
@@ -94,7 +94,7 @@ struct Q_QML_EXPORT QObjectWrapper : public QV4::Object
 
     void deleteQObject(bool deleteInstantly = false);
 
-    Value getProperty(ExecutionContext *ctx, String *name, RevisionMode revisionMode, bool *hasProperty = 0);
+    Value getQmlProperty(ExecutionContext *ctx, String *name, RevisionMode revisionMode, bool *hasProperty = 0, bool includeImports = false);
 
 private:
     QQmlGuard<QObject> m_object;