From 425edd90acfbb81b50f63db7f60927dcae197dfd Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 26 Oct 2017 10:52:19 +0200 Subject: V4 Debugger: Allow executing jobs on contexts without v4Function Previously this would crash as it tried to determine strict mode by querying the function. Check the functions of out contexts, too, and finally try the global context if none is found. Change-Id: Ib21c2f4f242a67909944b71640a154ff181c33e1 Reviewed-by: Lars Knoll --- src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 11 +++++++---- .../qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index e852f574a7..8b51574525 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -67,11 +67,11 @@ void JavaScriptJob::run() QV4::ScopedContext ctx(scope, engine->currentContext()); QObject scopeObject; + QV4::CppStackFrame *frame = engine->currentStackFrame; if (frameNr > 0) { - QV4::CppStackFrame *f = engine->currentStackFrame; for (int i = 0; i < frameNr; ++i) - f = f->parent; - ctx = static_cast(&f->jsFrame->context); + frame = frame->parent; + ctx = static_cast(&frame->jsFrame->context); } if (context >= 0) { @@ -103,7 +103,10 @@ void JavaScriptJob::run() } QV4::Script script(ctx, QV4::Compiler::EvalCode, this->script); - script.strictMode = ctx->d()->v4Function->isStrict(); + if (QV4::Function *function = frame->v4Function) + script.strictMode = function->isStrict(); + else if (engine->globalCode) + script.strictMode = engine->globalCode->isStrict(); // In order for property lookups in QML to work, we need to disable fast v4 lookups. That // is a side-effect of inheritContext. script.inheritContext = true; diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 7bf419a1d9..e8570a380f 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -252,7 +252,10 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) QV4::ExecutionContext *ctx = m_engine->currentContext(); QV4::Script script(ctx, QV4::Compiler::EvalCode, expression); - script.strictMode = ctx->d()->v4Function->isStrict(); + if (QV4::Function *function = m_engine->currentStackFrame->v4Function) + script.strictMode = function->isStrict(); + else if (m_engine->globalCode) + script.strictMode = m_engine->globalCode->isStrict(); // In order for property lookups in QML to work, we need to disable fast v4 lookups. // That is a side-effect of inheritContext. script.inheritContext = true; -- cgit v1.2.3