summaryrefslogtreecommitdiffstats
path: root/src/script
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-14 15:01:42 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-08-14 15:08:03 (GMT)
commit034d7d1c0893fe2b25379b109a82325fac96f0d1 (patch)
treec9afb9818474964c43e0c76205f3f821546f6706 /src/script
parent7c1e089fd3d2560322e643c6c1c3b1e73bf04c98 (diff)
downloadQt-034d7d1c0893fe2b25379b109a82325fac96f0d1.zip
Qt-034d7d1c0893fe2b25379b109a82325fac96f0d1.tar.gz
Qt-034d7d1c0893fe2b25379b109a82325fac96f0d1.tar.bz2
push the right object when the argument is the Global Object
Since the internal Global Object is never exposed to the public, we need to do like we do in setActivationObject(): if the object passed is the Global Object proxy, use the internal Global Object as the "real" argument. (JSC requires that the initial object pushed onto the scope chain is an instance of JSC::JSGlobalObject, and the Global Object proxy is not; hence, we can't push the proxy.)
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/qscriptcontext.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp
index 75ad505..e213f3b 100644
--- a/src/script/api/qscriptcontext.cpp
+++ b/src/script/api/qscriptcontext.cpp
@@ -711,13 +711,22 @@ void QScriptContext::pushScope(const QScriptValue &object)
return;
}
JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
- JSC::JSValue jscObject = QScript::scriptEngineFromExec(frame)->scriptValueToJSCValue(object);
+ QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame);
+ JSC::JSObject *jscObject = JSC::asObject(engine->scriptValueToJSCValue(object));
+ if (jscObject == engine->originalGlobalObjectProxy)
+ jscObject = engine->originalGlobalObject();
JSC::ScopeChainNode *scope = frame->scopeChain();
Q_ASSERT(scope != 0);
- if (!scope->object) // pushing to an "empty" chain
- scope->object = JSC::asObject(jscObject);
+ if (!scope->object) {
+ // pushing to an "empty" chain
+ if (!jscObject->isGlobalObject()) {
+ qWarning("QScriptContext::pushScope() failed: initial object in scope chain has to be the Global Object");
+ return;
+ }
+ scope->object = jscObject;
+ }
else
- frame->setScopeChain(scope->push(JSC::asObject(jscObject)));
+ frame->setScopeChain(scope->push(jscObject));
}
/*!