diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-03-03 07:14:07 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-03-03 07:15:01 (GMT) |
commit | 4690084e9f3fbf3635aa3fb6a8025ae046672aea (patch) | |
tree | e691c0745411ae0075cd507bc14799cc30c68124 /src/declarative/qml/qdeclarativeglobalscriptclass.cpp | |
parent | aebadf248a93458615a53b3480987f829aba0ee6 (diff) | |
download | Qt-4690084e9f3fbf3635aa3fb6a8025ae046672aea.zip Qt-4690084e9f3fbf3635aa3fb6a8025ae046672aea.tar.gz Qt-4690084e9f3fbf3635aa3fb6a8025ae046672aea.tar.bz2 |
Move JS global scope to top of the QML scope chain
QT-2787
Diffstat (limited to 'src/declarative/qml/qdeclarativeglobalscriptclass.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativeglobalscriptclass.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp index 5b06b42..9ee2fe5 100644 --- a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp @@ -53,15 +53,17 @@ QT_BEGIN_NAMESPACE QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(QScriptEngine *engine) : QScriptClass(engine) { - QScriptValue v = engine->newObject(); - globalObject = engine->globalObject(); + QScriptValue globalObject = engine->globalObject(); + m_globalObject = engine->newObject(); QScriptValueIterator iter(globalObject); while (iter.hasNext()) { iter.next(); - v.setProperty(iter.scriptName(), iter.value()); + m_globalObject.setProperty(iter.scriptName(), iter.value()); + m_illegalNames.insert(iter.name()); } + QScriptValue v = engine->newObject(); v.setScriptClass(this); engine->setGlobalObject(v); } @@ -101,12 +103,14 @@ void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object, engine()->currentContext()->throwError(error); } +/* This method is for the use of tst_qdeclarativeecmascript::callQtInvokables() only */ void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, const QScriptValue &value) { + QScriptValue globalObject = engine()->globalObject(); + QScriptValue v = engine()->newObject(); - globalObject = engine()->globalObject(); - QScriptValueIterator iter(globalObject); + QScriptValueIterator iter(v); while (iter.hasNext()) { iter.next(); v.setProperty(iter.scriptName(), iter.value()); @@ -114,6 +118,7 @@ void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, con v.setProperty(name, value); v.setScriptClass(this); + engine()->setGlobalObject(v); } |