diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 6 | ||||
| -rw-r--r-- | src/qml/qml/qqmlengine.cpp | 12 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index da3f3226f6..7e87b8be75 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -2112,7 +2112,11 @@ void ExecutionEngine::callInContext(Function *function, QObject *self, QMetaType *types) { QV4::Scope scope(this); - ExecutionContext *ctx = currentStackFrame ? currentContext() : scriptContext(); + // NB: always use scriptContext() here as this method ignores whether + // there's already a stack frame. the method is called from C++ (through + // QQmlEngine::executeRuntimeFunction()) and thus the caller must ensure + // correct setup + QV4::ExecutionContext *ctx = scriptContext(); QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(ctx, ctxtdata, self)); if (!args) { Q_ASSERT(argc == 0); diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index a914b2fd9d..ae7478e183 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -2266,19 +2266,15 @@ void QQmlEnginePrivate::executeRuntimeFunction(const QUrl &url, qsizetype functi if (!unit) return; - Q_ASSERT(functionIndex >= 0); + Q_ASSERT((functionIndex >= 0) && (functionIndex < unit->runtimeFunctions.length())); Q_ASSERT(thisObject); - if (unit->runtimeFunctions.length() <= functionIndex) - return; - - QQmlContext *ctx = q->contextForObject(thisObject); - if (!ctx) - ctx = q->rootContext(); + QQmlData *ddata = QQmlData::get(thisObject); + Q_ASSERT(ddata && ddata->outerContext); // implicitly sets the return value, if it is present q->handle()->callInContext(unit->runtimeFunctions[functionIndex], thisObject, - QQmlContextData::get(ctx), argc, args, types); + ddata->outerContext, argc, args, types); } QV4::ExecutableCompilationUnit *QQmlEnginePrivate::compilationUnitFromUrl(const QUrl &url) |
