summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qmlcontextscriptclass.cpp9
-rw-r--r--src/declarative/qml/qmlobjectscriptclass.cpp15
-rw-r--r--src/declarative/qml/qmlobjectscriptclass_p.h3
3 files changed, 19 insertions, 8 deletions
diff --git a/src/declarative/qml/qmlcontextscriptclass.cpp b/src/declarative/qml/qmlcontextscriptclass.cpp
index 939d008..ae86fb1 100644
--- a/src/declarative/qml/qmlcontextscriptclass.cpp
+++ b/src/declarative/qml/qmlcontextscriptclass.cpp
@@ -144,7 +144,7 @@ QmlContextScriptClass::queryProperty(QmlContext *bindContext, QObject *scopeObje
if (scopeObject) {
QScriptClass::QueryFlags rv =
- ep->objectClass->queryProperty(scopeObject, name, flags, 0);
+ ep->objectClass->queryProperty(scopeObject, name, flags, bindContext);
if (rv) {
lastScopeObject = scopeObject;
lastContext = bindContext;
@@ -154,7 +154,7 @@ QmlContextScriptClass::queryProperty(QmlContext *bindContext, QObject *scopeObje
for (int ii = 0; ii < cp->defaultObjects.count(); ++ii) {
QScriptClass::QueryFlags rv =
- ep->objectClass->queryProperty(cp->defaultObjects.at(ii), name, flags, 0);
+ ep->objectClass->queryProperty(cp->defaultObjects.at(ii), name, flags, bindContext);
if (rv) {
lastDefaultObject = ii;
@@ -225,9 +225,10 @@ void QmlContextScriptClass::setProperty(Object *object, const Identifier &name,
QmlContextPrivate *cp = QmlContextPrivate::get(bindContext);
if (lastScopeObject) {
- ep->objectClass->setProperty(lastScopeObject, name, value);
+ ep->objectClass->setProperty(lastScopeObject, name, value, bindContext);
} else {
- ep->objectClass->setProperty(cp->defaultObjects.at(lastDefaultObject), name, value);
+ ep->objectClass->setProperty(cp->defaultObjects.at(lastDefaultObject), name, value,
+ bindContext);
}
}
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)
diff --git a/src/declarative/qml/qmlobjectscriptclass_p.h b/src/declarative/qml/qmlobjectscriptclass_p.h
index 3fcf009..8d5b5f6 100644
--- a/src/declarative/qml/qmlobjectscriptclass_p.h
+++ b/src/declarative/qml/qmlobjectscriptclass_p.h
@@ -79,7 +79,8 @@ public:
QScriptClass::QueryFlags flags,
QmlContext *evalContext);
QScriptValue property(QObject *, const Identifier &);
- void setProperty(QObject *, const Identifier &name, const QScriptValue &);
+ void setProperty(QObject *, const Identifier &name, const QScriptValue &,
+ QmlContext *evalContext = 0);
protected:
virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,