diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-16 00:29:16 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-16 00:29:16 (GMT) |
commit | 8eec0b69e303d10582d04784a0bb200418272c4d (patch) | |
tree | cb0a4ef01f750df9dcf0b1ac8fcc00125da2c051 /src/declarative/qml/qmlobjectscriptclass.cpp | |
parent | e4e566272f41a27b7b160c6e1344d24f66ad022c (diff) | |
download | Qt-8eec0b69e303d10582d04784a0bb200418272c4d.zip Qt-8eec0b69e303d10582d04784a0bb200418272c4d.tar.gz Qt-8eec0b69e303d10582d04784a0bb200418272c4d.tar.bz2 |
Correctly pass context to QmlObjectScriptClass
Diffstat (limited to 'src/declarative/qml/qmlobjectscriptclass.cpp')
-rw-r--r-- | src/declarative/qml/qmlobjectscriptclass.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index ae2cfcc..c356a3f 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -242,7 +242,8 @@ void QmlObjectScriptClass::setProperty(Object *object, void QmlObjectScriptClass::setProperty(QObject *obj, const Identifier &name, - const QScriptValue &value) + const QScriptValue &value, + QmlContext *evalContext) { Q_UNUSED(name); @@ -250,12 +251,20 @@ void QmlObjectScriptClass::setProperty(QObject *obj, Q_ASSERT(lastData); QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine); - Q_ASSERT(enginePriv->currentExpression); + + if (!evalContext && context()) { + // Global object, QScriptContext activation object, QmlContext object + QScriptValue scopeNode = scopeChainValue(context(), -3); + Q_ASSERT(scopeNode.isValid()); + Q_ASSERT(scriptClass(scopeNode) == enginePriv->contextClass); + + evalContext = enginePriv->contextClass->contextFromValue(scopeNode); + } // ### Can well known types be optimized? QVariant v = QmlScriptClass::toVariant(engine, value); delete QmlMetaPropertyPrivate::setBinding(obj, *lastData, 0); - QmlMetaPropertyPrivate::write(obj, *lastData, v, enginePriv->currentExpression->context()); + QmlMetaPropertyPrivate::write(obj, *lastData, v, evalContext); } QObject *QmlObjectScriptClass::toQObject(Object *object, bool *ok) |