diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2017-10-27 11:30:43 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2017-11-07 11:06:58 +0000 |
commit | a5d31af1a58a2c833ed3ee91dd9140ab23fc8e8a (patch) | |
tree | da3e33a1053a9ef46d5d04da17c5865953460e6d /src/plugins | |
parent | 425edd90acfbb81b50f63db7f60927dcae197dfd (diff) |
Fix evaluation of V4 debug jobs
There may not be a current stack frame and there may not be a function
in either the current frame or the global scope.
Change-Id: I15daf10586cf8895a9a80ccc3dd4bf4117a947c5
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 16 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 8 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 8b51574525..cb40c9e36a 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -64,15 +64,16 @@ void JavaScriptJob::run() { QV4::Scope scope(engine); - QV4::ScopedContext ctx(scope, engine->currentContext()); + QV4::ScopedContext ctx(scope, engine->currentStackFrame ? engine->currentContext() + : engine->rootContext()); QObject scopeObject; QV4::CppStackFrame *frame = engine->currentStackFrame; - if (frameNr > 0) { - for (int i = 0; i < frameNr; ++i) - frame = frame->parent; + + for (int i = 0; frame && i < frameNr; ++i) + frame = frame->parent; + if (frameNr > 0 && frame) ctx = static_cast<QV4::ExecutionContext *>(&frame->jsFrame->context); - } if (context >= 0) { QQmlContext *extraContext = qmlContext(QQmlDebugService::objectForId(context)); @@ -103,10 +104,9 @@ void JavaScriptJob::run() } QV4::Script script(ctx, QV4::Compiler::EvalCode, this->script); - if (QV4::Function *function = frame->v4Function) + if (const QV4::Function *function = frame ? frame->v4Function : engine->globalCode) 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 e8570a380f..917d40fd6a 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -249,13 +249,13 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) QV4::Scope scope(m_engine); m_runningJob = true; - QV4::ExecutionContext *ctx = m_engine->currentContext(); + QV4::ExecutionContext *ctx = m_engine->currentStackFrame ? m_engine->currentContext() + : m_engine->rootContext(); QV4::Script script(ctx, QV4::Compiler::EvalCode, expression); - if (QV4::Function *function = m_engine->currentStackFrame->v4Function) + if (const QV4::Function *function = m_engine->currentStackFrame + ? m_engine->currentStackFrame->v4Function : m_engine->globalCode) 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; |