From 5eceb1801ec881947f80f70f32ea46e00926194f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 26 Jun 2019 14:37:36 +0200 Subject: Fix thisObject when calling scope and context properties through lookups Just like resolving the lookup initially, we need to set the base also when hitting the cached lookup code path. The base is then used as this object. Fixes: QTBUG-76656 Change-Id: I6f6be05bc9875ddccc6e112e91176a0fa24a8fa1 Reviewed-by: Michael Brasser Reviewed-by: Ulf Hermann --- src/qml/jsruntime/qv4qmlcontext.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/qml/jsruntime/qv4qmlcontext.cpp') diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp index 6aa0130188..969d44ecf6 100644 --- a/src/qml/jsruntime/qv4qmlcontext.cpp +++ b/src/qml/jsruntime/qv4qmlcontext.cpp @@ -539,7 +539,6 @@ ReturnedValue QQmlContextWrapper::lookupIdObject(Lookup *l, ExecutionEngine *eng ReturnedValue QQmlContextWrapper::lookupScopeObjectProperty(Lookup *l, ExecutionEngine *engine, Value *base) { - Q_UNUSED(base) Scope scope(engine); Scoped qmlContext(scope, engine->qmlContext()); if (!qmlContext) @@ -560,12 +559,15 @@ ReturnedValue QQmlContextWrapper::lookupScopeObjectProperty(Lookup *l, Execution }; ScopedValue obj(scope, QV4::QObjectWrapper::wrap(engine, scopeObject)); + + if (base) + *base = obj; + return QObjectWrapper::lookupGetterImpl(l, engine, obj, /*useOriginalProperty*/ true, revertLookup); } ReturnedValue QQmlContextWrapper::lookupContextObjectProperty(Lookup *l, ExecutionEngine *engine, Value *base) { - Q_UNUSED(base) Scope scope(engine); Scoped qmlContext(scope, engine->qmlContext()); if (!qmlContext) @@ -590,6 +592,10 @@ ReturnedValue QQmlContextWrapper::lookupContextObjectProperty(Lookup *l, Executi }; ScopedValue obj(scope, QV4::QObjectWrapper::wrap(engine, contextObject)); + + if (base) + *base = obj; + return QObjectWrapper::lookupGetterImpl(l, engine, obj, /*useOriginalProperty*/ true, revertLookup); } -- cgit v1.2.3