diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2017-10-26 10:52:19 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2017-11-07 09:19:40 +0000 |
commit | 425edd90acfbb81b50f63db7f60927dcae197dfd (patch) | |
tree | 012c991cf2e5f68ccd0c04b2ef6f2f0a8705355e /src/plugins | |
parent | 3f37847fc3758d66cb16e8e070c29ac5b39dbc7a (diff) |
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 <lars.knoll@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 11 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 5 |
2 files changed, 11 insertions, 5 deletions
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<QV4::ExecutionContext *>(&f->jsFrame->context); + frame = frame->parent; + ctx = static_cast<QV4::ExecutionContext *>(&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; |