... with the help of a getQmlProperty static function.
Change-Id: Ia823ba9ac995cb1a0591081bf18418f48d60e04d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
// Search scope object
if (scopeObject) {
- if (QV4::QObjectWrapper *o = QV4::QObjectWrapper::wrap(ctx->engine, scopeObject).as<QV4::QObjectWrapper>()) {
- bool hasProp = false;
- QV4::Value result = o->getQmlProperty(ctx, context, name, QV4::QObjectWrapper::CheckRevision, &hasProp);
- if (hasProp) {
- if (hasProperty)
- *hasProperty = true;
- return result;
- }
+ bool hasProp = false;
+ QV4::Value result = QV4::QObjectWrapper::getQmlProperty(ctx, context, scopeObject, name, QV4::QObjectWrapper::CheckRevision, &hasProp);
+ if (hasProp) {
+ if (hasProperty)
+ *hasProperty = true;
+ return result;
}
}
scopeObject = 0;
// Search context object
if (context->contextObject) {
- if (QV4::QObjectWrapper *o = QV4::QObjectWrapper::wrap(ctx->engine, context->contextObject).as<QV4::QObjectWrapper>()) {
- bool hasProp = false;
- QV4::Value result = o->getQmlProperty(ctx, context, name, QV4::QObjectWrapper::CheckRevision, &hasProp);
- if (hasProp) {
- if (hasProperty)
- *hasProperty = true;
- return result;
- }
+ bool hasProp = false;
+ QV4::Value result = QV4::QObjectWrapper::getQmlProperty(ctx, context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, &hasProp);
+ if (hasProp) {
+ if (hasProperty)
+ *hasProperty = true;
+ return result;
}
}
}
// check for property.
- if (QV4::QObjectWrapper *o = QV4::QObjectWrapper::wrap(ctx->engine, qobjectSingleton).as<QV4::QObjectWrapper>())
- return o->getQmlProperty(ctx, context, name, QV4::QObjectWrapper::IgnoreRevision);
- else
- return QV4::Value::undefinedValue();
+ return QV4::QObjectWrapper::getQmlProperty(ctx, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision);
} 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.
} else if (w->object) {
QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
- if (ao) {
- QV4::QObjectWrapper *wrapper = QV4::QObjectWrapper::wrap(ctx->engine, ao).as<QV4::QObjectWrapper>();
- if (wrapper)
- return wrapper->getQmlProperty(ctx, context, name, QV4::QObjectWrapper::IgnoreRevision);
- }
+ if (ao)
+ return QV4::QObjectWrapper::getQmlProperty(ctx, context, ao, name, QV4::QObjectWrapper::IgnoreRevision);
// Fall through to base implementation
}
if (result->isFunction()) {
// calling a Q_INVOKABLE function of a value type
QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(ctx->engine);
- return QV4::QObjectWrapper::wrap(ctx->engine, r->type).as<QV4::QObjectWrapper>()->getQmlProperty(ctx, qmlContext, name, QV4::QObjectWrapper::IgnoreRevision);
+ return QV4::QObjectWrapper::getQmlProperty(ctx, qmlContext, r->type, name, QV4::QObjectWrapper::IgnoreRevision);
}
#define VALUE_TYPE_LOAD(metatype, cpptype, constructor) \
}
}
+Value QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextData *qmlContext, QObject *object, String *name, QObjectWrapper::RevisionMode revisionMode, bool *hasProperty)
+{
+ if (QQmlData::wasDeleted(object)) {
+ if (hasProperty)
+ *hasProperty = false;
+ return QV4::Value::nullValue();
+ }
+
+ if (!QQmlData::get(object, true)) {
+ if (hasProperty)
+ *hasProperty = false;
+ return QV4::Value::nullValue();
+ }
+
+ QObjectWrapper *wrapper = wrap(ctx->engine, object).as<QV4::QObjectWrapper>();
+ if (!wrapper) {
+ if (hasProperty)
+ *hasProperty = false;
+ return QV4::Value::nullValue();
+ }
+ return wrapper->getQmlProperty(ctx, qmlContext, name, revisionMode, hasProperty);
+}
+
Value QObjectWrapper::wrap(ExecutionEngine *engine, QObject *object)
{
if (QQmlData::wasDeleted(object))
void deleteQObject(bool deleteInstantly = false);
Value getQmlProperty(ExecutionContext *ctx, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, bool *hasProperty = 0, bool includeImports = false);
+ static Value getQmlProperty(ExecutionContext *ctx, QQmlContextData *qmlContext, QObject *object, String *name, RevisionMode revisionMode, bool *hasProperty = 0);
static Value wrap(ExecutionEngine *engine, QObject *object);