diff options
author | Kari Oikarinen <kari.oikarinen@qt.io> | 2019-04-01 09:17:01 +0300 |
---|---|---|
committer | Kari Oikarinen <kari.oikarinen@qt.io> | 2019-04-01 09:17:01 +0300 |
commit | 8c1c579405cb4a3b039b171a1fa5d636deed9511 (patch) | |
tree | 03cf54534220221cb4c4ddc85288ecaa052d8252 /src/qml/jsruntime/qv4qmlcontext.cpp | |
parent | 8ec25f301d08e981ca066755ffea582c5cbdf1b0 (diff) | |
parent | 42f0b0b245d29118e91fffaddeafcbdb8b48cc63 (diff) |
Merge 5.12 into 5.12.3
Change-Id: Ic25bb7ba2e9f404622157ef023e64c3d4d47263f
Diffstat (limited to 'src/qml/jsruntime/qv4qmlcontext.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4qmlcontext.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp index a2c8e3916f..12ada7ee70 100644 --- a/src/qml/jsruntime/qv4qmlcontext.cpp +++ b/src/qml/jsruntime/qv4qmlcontext.cpp @@ -465,10 +465,23 @@ ReturnedValue QQmlContextWrapper::resolveQmlContextPropertyLookupGetter(Lookup * return static_cast<Heap::CallContext*>(ctx.d())->locals[index].asReturnedValue(); } - Scoped<QQmlContextWrapper> qmlContext(scope, engine->qmlContext()->qml()); bool hasProperty = false; - ScopedValue result(scope, QQmlContextWrapper::getPropertyAndBase(qmlContext, name, /*receiver*/nullptr, - &hasProperty, base, l)); + ScopedValue result(scope); + + Scoped<QmlContext> callingQmlContext(scope, engine->qmlContext()); + if (callingQmlContext) { + Scoped<QQmlContextWrapper> qmlContextWrapper(scope, callingQmlContext->d()->qml()); + result = QQmlContextWrapper::getPropertyAndBase(qmlContextWrapper, name, /*receiver*/nullptr, &hasProperty, + base, l); + } else { + // Code path typical to worker scripts, compiled with lookups but no qml context. + result = l->resolveGlobalGetter(engine); + if (l->globalGetter != Lookup::globalGetterGeneric) { + hasProperty = true; + l->qmlContextGlobalLookup.getterTrampoline = l->globalGetter; + l->qmlContextPropertyGetter = QQmlContextWrapper::lookupInGlobalObject; + } + } if (!hasProperty) return engine->throwReferenceError(name.toQString()); return result->asReturnedValue(); |