diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2018-03-16 14:51:15 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-03-17 10:29:44 +0000 |
commit | 61447075954aab99b3abc9c78294e5966ae3b6ce (patch) | |
tree | 68192e06f529b2f2613d2541ea6063fa6fcba8ec /src/plugins | |
parent | 80b5f8c2f448be574e731e5d371c38b84578f5c3 (diff) |
Pass "this" object when evaluating debug jobs
We have to explicitly specify the "this" object on QV4::Function::call,
otherwise it will assume undefined or the QML global object.
Task-number: QTBUG-66942
Change-Id: I1af7742b4fee1b49e9760a413834daf3edb15d74
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 10 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 10 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 5b049ab521..7950d21612 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -112,8 +112,14 @@ void JavaScriptJob::run() script.inheritContext = true; script.parse(); QV4::ScopedValue result(scope); - if (!scope.engine->hasException) - result = script.run(); + if (!scope.engine->hasException) { + if (frame) { + QV4::ScopedValue thisObject(scope, frame->thisObject()); + result = script.run(thisObject); + } else { + result = script.run(); + } + } if (scope.engine->hasException) { result = scope.engine->catchException(); resultIsException = true; diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 718975275a..e17fe92983 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -260,8 +260,14 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) // That is a side-effect of inheritContext. script.inheritContext = true; script.parse(); - if (!m_engine->hasException) - return script.run(); + if (!m_engine->hasException) { + if (m_engine->currentStackFrame) { + QV4::ScopedValue thisObject(scope, m_engine->currentStackFrame->thisObject()); + script.run(thisObject); + } else { + script.run(); + } + } m_runningJob = false; return QV4::Encode::undefined(); |