diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-08-14 12:20:56 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-08-14 12:20:56 (GMT) |
commit | 4c31f59d45130eae8f140e6d0177a4b227454187 (patch) | |
tree | f03c06fc796c7ae254c342d4016ef13f5c0a3c5e | |
parent | e0a86dc604b87921652b844a5f85889bb6291ed9 (diff) | |
download | Qt-4c31f59d45130eae8f140e6d0177a4b227454187.zip Qt-4c31f59d45130eae8f140e6d0177a4b227454187.tar.gz Qt-4c31f59d45130eae8f140e6d0177a4b227454187.tar.bz2 |
make sure QScriptContext::scopeChain() returns the right object
Follow-up to commit e0a86dc604b87921652b844a5f85889bb6291ed9.
Just like in the activationObject() function, we need to check if
the activation object is actually a proxy to another object, and
return that other object if that's the case (the proxy object should
not be exposed to the public).
-rw-r--r-- | src/script/api/qscriptcontext.cpp | 11 | ||||
-rw-r--r-- | tests/auto/qscriptcontext/tst_qscriptcontext.cpp | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp index 4a78f7c..01ccb6d 100644 --- a/src/script/api/qscriptcontext.cpp +++ b/src/script/api/qscriptcontext.cpp @@ -671,8 +671,15 @@ QScriptValueList QScriptContext::scopeChain() const JSC::ScopeChainNode *node = frame->scopeChain(); JSC::ScopeChainIterator it(node); for (it = node->begin(); it != node->end(); ++it) { - if (*it) - result.append(engine->scriptValueFromJSCValue(*it)); + JSC::JSObject *object = *it; + if (!object) + continue; + if (object->isObject(&QScript::QScriptActivationObject::info) + && (static_cast<QScript::QScriptActivationObject*>(object)->delegate() != 0)) { + // Return the object that property access is being delegated to + object = static_cast<QScript::QScriptActivationObject*>(object)->delegate(); + } + result.append(engine->scriptValueFromJSCValue(object)); } return result; } diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index 6401f62..36c680d 100644 --- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp +++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp @@ -719,6 +719,8 @@ void tst_QScriptContext::getSetActivationObject() QScriptValue obj = eng.newObject(); ctx->setActivationObject(obj); QVERIFY(ctx->activationObject().equals(obj)); + QCOMPARE(ctx->scopeChain().size(), 1); + QVERIFY(ctx->scopeChain().at(0).equals(obj)); { QScriptEngine eng2; |