aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlcontextwrapper.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-08-08 14:57:36 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-08 15:35:26 +0200
commit3b8457712e7b98dd6ee88f0290deabdf46695598 (patch)
tree758bbd21cf25294ce35e17109fe761101c3aa2e5 /src/qml/qml/qqmlcontextwrapper.cpp
parent8a273812ce2a9055d7cf2196e1b8a288bf0fc142 (diff)
Fix tst_qqmlecmascript::scope() and behavioural compatibility with v8 based qml
In the V8 based QML the global object would come _before_ the "QML global object", which is the QML context (wrapper). We had a bunch of tests that verify the exact scope chain and with this "compatibility" fix we can re-enable them. Also fix missing prototype setup for the console object. Change-Id: Ib3886f2d86472eb752a6ad1a2d8d89709548c5b4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlcontextwrapper.cpp')
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index 4a66c7552d..9ba3a51757 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -133,14 +133,23 @@ Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
if (!resource)
v4->current->throwTypeError();
+ // In V8 the JS global object would come _before_ the QML global object,
+ // so simulate that here.
+ bool hasProp;
+ QV4::Value result = v4->globalObject->get(name, &hasProp);
+ if (hasProp) {
+ if (hasProperty)
+ *hasProperty = hasProp;
+ return result;
+ }
+
if (resource->isNullWrapper)
return Object::get(m, name, hasProperty);
if (QV4::QmlContextWrapper::callingContext(v4) != resource->context)
return Object::get(m, name, hasProperty);
- bool hasProp;
- Value result = Object::get(m, name, &hasProp);
+ result = Object::get(m, name, &hasProp);
if (hasProp) {
if (hasProperty)
*hasProperty = hasProp;