diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-09-23 04:33:25 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-09-23 04:40:41 (GMT) |
commit | d5c1df72cecda0344717224fede54d83b6d5f15b (patch) | |
tree | fd85dd310cf42568cca121616adbec8a64f51bdc /src/declarative/qml | |
parent | 9d605890a9e25623926c2dfff6a287093ff93778 (diff) | |
download | Qt-d5c1df72cecda0344717224fede54d83b6d5f15b.zip Qt-d5c1df72cecda0344717224fede54d83b6d5f15b.tar.gz Qt-d5c1df72cecda0344717224fede54d83b6d5f15b.tar.bz2 |
Remove binding when writing to a property
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmlmetaproperty.cpp | 18 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetaproperty_p.h | 6 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 91769d3..efc4a2b 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -119,6 +119,7 @@ QmlMetaObjectCache::property(const QString &name, const QMetaObject *metaObject) QmlMetaProperty::QmlMetaProperty() : d(new QmlMetaPropertyPrivate) { + d->q = this; } /*! @@ -134,7 +135,9 @@ QmlMetaProperty::~QmlMetaProperty() default property, an invalid QmlMetaProperty will be created. */ QmlMetaProperty::QmlMetaProperty(QObject *obj) +: d(new QmlMetaPropertyPrivate) { + d->q = this; d->initDefault(obj); } @@ -146,6 +149,7 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj) QmlMetaProperty::QmlMetaProperty(QObject *obj, QmlContext *ctxt) : d(new QmlMetaPropertyPrivate) { + d->q = this; d->context = ctxt; d->initDefault(obj); } @@ -175,6 +179,7 @@ void QmlMetaPropertyPrivate::initDefault(QObject *obj) QmlMetaProperty::QmlMetaProperty(QObject *obj, int idx, QmlContext *ctxt) : d(new QmlMetaPropertyPrivate) { + d->q = this; d->context = ctxt; d->object = obj; d->type = Property; @@ -191,6 +196,7 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, int idx, QmlContext *ctxt) QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name) : d(new QmlMetaPropertyPrivate) { + d->q = this; d->initProperty(obj, name); } @@ -201,6 +207,7 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name) QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name, QmlContext *ctxt) : d(new QmlMetaPropertyPrivate) { + d->q = this; d->context = ctxt; d->initProperty(obj, name); } @@ -276,6 +283,7 @@ void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name) QmlMetaProperty::QmlMetaProperty(const QmlMetaProperty &other) : d(new QmlMetaPropertyPrivate(*other.d)) { + d->q = this; } /*! @@ -560,9 +568,10 @@ QmlMetaProperty::setBinding(QmlAbstractBinding *newBinding) const if (!isProperty() || (type() & Attached) || !d->object) return 0; - QmlDeclarativeData *data = QmlDeclarativeData::get(d->object, true); + QmlDeclarativeData *data = + QmlDeclarativeData::get(d->object, 0 != newBinding); - if (data->hasBindingBit(d->coreIdx)) { + if (data && data->hasBindingBit(d->coreIdx)) { QmlAbstractBinding *binding = data->bindings; while (binding) { // ### This wont work for value types @@ -584,7 +593,6 @@ QmlMetaProperty::setBinding(QmlAbstractBinding *newBinding) const return 0; } - /*! Returns the expression associated with this signal property, or 0 if no signal expression exists. @@ -743,6 +751,10 @@ void QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value, int writeBackIdx = -1; bool deleteWriteBack = false; + // Remove any existing bindings on this property + if (source != QmlMetaProperty::Binding) + delete q->setBinding(0); + if (type & QmlMetaProperty::ValueTypeProperty) { QmlEnginePrivate *ep = context?static_cast<QmlEnginePrivate *>(QObjectPrivate::get(context->engine())):0; diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h index f2d0039..1ccf913 100644 --- a/src/declarative/qml/qmlmetaproperty_p.h +++ b/src/declarative/qml/qmlmetaproperty_p.h @@ -85,16 +85,18 @@ class QmlMetaPropertyPrivate { public: QmlMetaPropertyPrivate() - : context(0), coreIdx(-1), valueTypeIdx(-1), valueTypeId(0), + : q(0), context(0), coreIdx(-1), valueTypeIdx(-1), valueTypeId(0), type(QmlMetaProperty::Invalid), attachedFunc(-1), object(0), propType(-1), category(QmlMetaProperty::Unknown) {} QmlMetaPropertyPrivate(const QmlMetaPropertyPrivate &other) - : name(other.name), signal(other.signal), context(other.context), + : q(0), name(other.name), signal(other.signal), context(other.context), coreIdx(other.coreIdx), valueTypeIdx(other.valueTypeIdx), valueTypeId(other.valueTypeId), type(other.type), attachedFunc(other.attachedFunc), object(other.object), propType(other.propType), category(other.category) {} + QmlMetaProperty *q; + QString name; QMetaMethod signal; QmlContext *context; |