aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp10
-rw-r--r--src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp10
-rw-r--r--src/qml/jsruntime/qv4script.cpp7
-rw-r--r--src/qml/jsruntime/qv4script_p.h2
4 files changed, 21 insertions, 8 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();
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index bb6608bec0..267c93952d 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -136,7 +136,7 @@ void Script::parse()
}
}
-ReturnedValue Script::run()
+ReturnedValue Script::run(const QV4::Value *thisObject)
{
if (!parsed)
parse();
@@ -149,10 +149,11 @@ ReturnedValue Script::run()
if (qmlContext.isUndefined()) {
TemporaryAssignment<Function*> savedGlobalCode(engine->globalCode, vmFunction);
- return vmFunction->call(engine->globalObject, nullptr, 0, context);
+ return vmFunction->call(thisObject ? thisObject : engine->globalObject, nullptr, 0,
+ context);
} else {
Scoped<QmlContext> qml(valueScope, qmlContext.value());
- return vmFunction->call(nullptr, nullptr, 0, qml);
+ return vmFunction->call(thisObject, nullptr, 0, qml);
}
}
diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h
index 24291b9aa6..cb03c6b064 100644
--- a/src/qml/jsruntime/qv4script_p.h
+++ b/src/qml/jsruntime/qv4script_p.h
@@ -93,7 +93,7 @@ struct Q_QML_EXPORT Script {
bool parseAsBinding;
void parse();
- ReturnedValue run();
+ ReturnedValue run(const QV4::Value *thisObject = nullptr);
Function *function();