aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2018-02-15 11:51:25 +0100
committerErik Verbruggen <erik.verbruggen@qt.io>2018-02-15 14:23:16 +0000
commitb2420780df98cb3c98553da18a5b1bc5b64e9e83 (patch)
treec5d19d6091e378c082fde5da1be6e4eb7d87c691 /src
parentd19127807c193d612c6fee4f3418a8c8af9d262c (diff)
Correctly set this object when calling scope/context functions
When a function is called that is in a QML scope or a QML context, set the 'this' object to the QML scope. Note: this patch is 5.9 specific. 5.11 has a similair issue, but the implementation is quite different, so that needs a separate fix. Task-number: QTBUG-59357 Change-Id: Ia78e012d413c40a094e957f4020502cd055ac286 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 28b344d154..124b246701 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -1064,6 +1064,8 @@ ReturnedValue Runtime::method_callQmlScopeObjectProperty(ExecutionEngine *engine
return engine->throwTypeError(error);
}
+ auto scopeObj = static_cast<const QmlContext &>(callData->thisObject).d()->qml->scopeObject;
+ callData->thisObject = QObjectWrapper::wrap(engine, scopeObj);
o->call(scope, callData);
return scope.result.asReturnedValue();
}
@@ -1077,6 +1079,8 @@ ReturnedValue Runtime::method_callQmlContextObjectProperty(ExecutionEngine *engi
return engine->throwTypeError(error);
}
+ auto scopeObj = static_cast<const QmlContext &>(callData->thisObject).d()->qml->context->contextData()->contextObject;
+ callData->thisObject = QObjectWrapper::wrap(engine, scopeObj);
o->call(scope, callData);
return scope.result.asReturnedValue();
}