From a5cc9714deb37281d97f03f3eaf23ebd0be41f0f Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 10 Aug 2009 11:03:51 +0200 Subject: make ResolveScope property lookup work (kind of) Look in the __qt_scope__ property that is set by QScriptValue::setScope(). --- src/script/api/qscriptvalue.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index b24c67a..d2569ae 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -371,9 +371,16 @@ QScriptValue QScriptValuePrivate::property(const JSC::Identifier &id, int resolv JSC::JSValue result; if (const_cast(object)->getOwnPropertySlot(exec, id, slot)) { result = slot.getValue(exec, id); - } else if ((resolveMode & QScriptValue::ResolvePrototype) + } else { + if ((resolveMode & QScriptValue::ResolvePrototype) && const_cast(object)->getPropertySlot(exec, id, slot)) { - result = slot.getValue(exec, id); + result = slot.getValue(exec, id); + } else if (resolveMode & QScriptValue::ResolveScope) { + // ### check if it's a function object and look in the scope chain + QScriptValue scope = property(QString::fromLatin1("__qt_scope__"), QScriptValue::ResolveLocal); + if (scope.isObject()) + result = eng_p->scriptValueToJSCValue(QScriptValuePrivate::get(scope)->property(id, resolveMode)); + } } return eng_p->scriptValueFromJSCValue(result); } -- cgit v0.12