From bb8c3d4f8f064bf53b22d85f875c8adffc2591c0 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 19 Nov 2009 09:59:28 +1000 Subject: 'when' property has to be before 'value' property in Binding element Task-number: QTBUG-5477 --- src/declarative/util/qmlbind.cpp | 14 +++++++++++--- src/declarative/util/qmlbind_p.h | 7 +++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qmlbind.cpp index b8ab53e..2f692d8 100644 --- a/src/declarative/util/qmlbind.cpp +++ b/src/declarative/util/qmlbind.cpp @@ -55,9 +55,10 @@ QT_BEGIN_NAMESPACE class QmlBindPrivate : public QObjectPrivate { public: - QmlBindPrivate() : when(true), obj(0) {} + QmlBindPrivate() : when(true), componentComplete(false), obj(0) {} - bool when; + bool when : 1; + bool componentComplete : 1; QObject *obj; QString prop; QmlNullableValue value; @@ -176,10 +177,17 @@ void QmlBind::setValue(const QVariant &v) eval(); } +void QmlBind::componentComplete() +{ + Q_D(QmlBind); + d->componentComplete = true; + eval(); +} + void QmlBind::eval() { Q_D(QmlBind); - if (!d->obj || d->value.isNull || !d->when) + if (!d->obj || d->value.isNull || !d->when || !d->componentComplete) return; QmlMetaProperty prop(d->obj, d->prop); diff --git a/src/declarative/util/qmlbind_p.h b/src/declarative/util/qmlbind_p.h index a9b7b98..4d85698 100644 --- a/src/declarative/util/qmlbind_p.h +++ b/src/declarative/util/qmlbind_p.h @@ -52,11 +52,11 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QmlBindPrivate; -class Q_DECLARATIVE_EXPORT QmlBind : public QObject +class Q_DECLARATIVE_EXPORT QmlBind : public QObject, public QmlParserStatus { Q_OBJECT Q_DECLARE_PRIVATE(QmlBind) - + Q_INTERFACES(QmlParserStatus) Q_PROPERTY(QObject *target READ object WRITE setObject) Q_PROPERTY(QString property READ property WRITE setProperty) Q_PROPERTY(QVariant value READ value WRITE setValue) @@ -78,6 +78,9 @@ public: QVariant value() const; void setValue(const QVariant &); +protected: + virtual void componentComplete(); + private: void eval(); }; -- cgit v0.12