diff options
-rw-r--r-- | src/declarative/qml/qmlbinding.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontextscriptclass.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlexpression.cpp | 20 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetaproperty.cpp | 16 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetaproperty_p.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlobjectscriptclass.cpp | 11 | ||||
-rw-r--r-- | src/declarative/qml/qmlpropertycache.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlvaluetypescriptclass.cpp | 2 |
8 files changed, 30 insertions, 25 deletions
diff --git a/src/declarative/qml/qmlbinding.h b/src/declarative/qml/qmlbinding.h index 675917d..e3a297c 100644 --- a/src/declarative/qml/qmlbinding.h +++ b/src/declarative/qml/qmlbinding.h @@ -73,6 +73,7 @@ public: private: friend class QmlDeclarativeData; friend class QmlMetaProperty; + friend class QmlMetaPropertyPrivate; friend class QmlVME; QObject *m_object; diff --git a/src/declarative/qml/qmlcontextscriptclass.cpp b/src/declarative/qml/qmlcontextscriptclass.cpp index 8f45870..226c34c 100644 --- a/src/declarative/qml/qmlcontextscriptclass.cpp +++ b/src/declarative/qml/qmlcontextscriptclass.cpp @@ -146,7 +146,7 @@ QScriptValue QmlContextScriptClass::property(Object *object, const Identifier &n rv = ep->objectClass->newQObject(cp->idValues[lastPropertyIndex].data()); } else { QVariant value = cp->propertyValues.at(lastPropertyIndex); - return ep->scriptValueFromVariant(value); + rv = ep->scriptValueFromVariant(value); } ep->capturedProperties << diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index adf5261..61c14a9 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -296,13 +296,8 @@ QVariant QmlExpressionPrivate::evalQtScript(QObject *secondaryScope) QList<QObject *> list; for (int ii = 0; ii < length; ++ii) { QScriptValue arrayItem = svalue.property(ii); - QObject *d = - qvariant_cast<QObject *>(arrayItem.data().toVariant()); - if (d) { - list << d; - } else { - list << 0; - } + QObject *d = arrayItem.toQObject(); + list << d; } rv = QVariant::fromValue(list); } @@ -316,13 +311,10 @@ QVariant QmlExpressionPrivate::evalQtScript(QObject *secondaryScope) !svalue.isQMetaObject() && !svalue.isQObject() && !svalue.isRegExp()) { - QScriptValue objValue = svalue.data(); - if (objValue.isValid()) { - QVariant var = objValue.toVariant(); - if (var.userType() >= (int)QVariant::UserType && - QmlMetaType::isObject(var.userType())) - rv = var; - } + + QObject *o = svalue.toQObject(); + if (o) + return qVariantFromValue(o); } if (rv.isNull()) rv = svalue.toVariant(); diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 477377e..155b34a 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -564,14 +564,20 @@ QmlMetaProperty::setBinding(QmlAbstractBinding *newBinding) const if (!isProperty() || (type() & Attached) || !d->object) return 0; - QmlDeclarativeData *data = - QmlDeclarativeData::get(d->object, 0 != newBinding); + d->setBinding(d->object, d->core, newBinding); +} + +QmlAbstractBinding * +QmlMetaPropertyPrivate::setBinding(QObject *object, const QmlPropertyCache::Data &core, + QmlAbstractBinding *newBinding) +{ + QmlDeclarativeData *data = QmlDeclarativeData::get(object, 0 != newBinding); - if (data && data->hasBindingBit(d->core.coreIndex)) { + if (data && data->hasBindingBit(core.coreIndex)) { QmlAbstractBinding *binding = data->bindings; while (binding) { // ### This wont work for value types - if (binding->propertyIndex() == d->core.coreIndex) { + if (binding->propertyIndex() == core.coreIndex) { binding->setEnabled(false); if (newBinding) @@ -1124,7 +1130,7 @@ void QmlMetaProperty::restore(quint32 id, QObject *obj, QmlContext *ctxt) d->core.load(p); d->valueTypeCoreIdx = valueTypeIdx; - d->valueTypePropType = p.userType(); + d->valueTypePropType = p2.userType(); } else if (type & Property) { QmlPropertyCache *cache = enginePrivate?enginePrivate->cache(obj):0; diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h index 729236b..00b9c3a 100644 --- a/src/declarative/qml/qmlmetaproperty_p.h +++ b/src/declarative/qml/qmlmetaproperty_p.h @@ -101,6 +101,7 @@ public: QVariant readValueProperty(); void writeValueProperty(const QVariant &, QmlMetaProperty::WriteSource); static void write(QObject *, const QmlPropertyCache::Data &, const QVariant &, QmlContext *); + static QmlAbstractBinding *setBinding(QObject *, const QmlPropertyCache::Data &, QmlAbstractBinding *); static quint32 saveValueType(int, int); static quint32 saveProperty(int); diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index 7c7b13f..2d5991c 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -45,6 +45,7 @@ #include <private/qmlcontext_p.h> #include <private/qmldeclarativedata_p.h> #include <private/qmltypenamescriptclass_p.h> +#include <QtDeclarative/qmlbinding.h> QT_BEGIN_NAMESPACE @@ -181,6 +182,11 @@ QScriptValue QmlObjectScriptClass::property(QObject *obj, const Identifier &name QScriptValue sobj = scriptEngine->newQObject(obj); return sobj.property(toString(name)); } else { + if (!(lastData->flags & QmlPropertyCache::Data::IsConstant)) { + enginePriv->capturedProperties << + QmlEnginePrivate::CapturedProperty(obj, lastData->coreIndex, lastData->notifyIndex); + } + if ((uint)lastData->propType < QVariant::UserType) { QmlValueType *valueType = enginePriv->valueTypes[lastData->propType]; if (valueType) @@ -188,10 +194,6 @@ QScriptValue QmlObjectScriptClass::property(QObject *obj, const Identifier &name } QVariant var = obj->metaObject()->property(lastData->coreIndex).read(obj); - if (!(lastData->flags & QmlPropertyCache::Data::IsConstant)) { - enginePriv->capturedProperties << - QmlEnginePrivate::CapturedProperty(obj, lastData->coreIndex, lastData->notifyIndex); - } if (lastData->flags & QmlPropertyCache::Data::IsQObjectDerived) { QObject *rv = *(QObject **)var.constData(); @@ -223,6 +225,7 @@ void QmlObjectScriptClass::setProperty(QObject *obj, // ### 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()); } diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp index d7b087b..300bbf6 100644 --- a/src/declarative/qml/qmlpropertycache.cpp +++ b/src/declarative/qml/qmlpropertycache.cpp @@ -48,6 +48,8 @@ QT_BEGIN_NAMESPACE void QmlPropertyCache::Data::load(const QMetaProperty &p) { propType = p.userType(); + if (propType == QVariant::LastType) + propType = qMetaTypeId<QVariant>(); coreIndex = p.propertyIndex(); notifyIndex = p.notifySignalIndex(); name = QLatin1String(p.name()); diff --git a/src/declarative/qml/qmlvaluetypescriptclass.cpp b/src/declarative/qml/qmlvaluetypescriptclass.cpp index 503d64f..6fd674a 100644 --- a/src/declarative/qml/qmlvaluetypescriptclass.cpp +++ b/src/declarative/qml/qmlvaluetypescriptclass.cpp @@ -112,7 +112,7 @@ QScriptValue QmlValueTypeScriptClass::property(const QScriptValue &object, QMetaProperty p = ref.type->metaObject()->property(id); QVariant rv = p.read(ref.type); - return static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine))->scriptEngine.newVariant(rv); + return static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine))->scriptValueFromVariant(rv); } void QmlValueTypeScriptClass::setProperty(QScriptValue &object, |