summaryrefslogtreecommitdiffstats
path: root/src/declarative/util/qdeclarativebehavior.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-04-28 23:30:24 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-04-29 00:16:12 (GMT)
commitb3fc4d9671cf885cbd7145f125af9da190716d78 (patch)
tree41efd914aed9a980503f9f3c3055a84dc35b36ae /src/declarative/util/qdeclarativebehavior.cpp
parent9c97294f12fa155e90a702d952460b4911504a92 (diff)
downloadQt-b3fc4d9671cf885cbd7145f125af9da190716d78.zip
Qt-b3fc4d9671cf885cbd7145f125af9da190716d78.tar.gz
Qt-b3fc4d9671cf885cbd7145f125af9da190716d78.tar.bz2
Prevent Behavior from being triggered on initialization.
Add an additional private notification mechanism that is triggered after all QDeclarativeParserStatus items have had their componentComplete called. Task-number: QTBUG-6332
Diffstat (limited to 'src/declarative/util/qdeclarativebehavior.cpp')
-rw-r--r--src/declarative/util/qdeclarativebehavior.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp
index 1089d31..90344ab 100644
--- a/src/declarative/util/qdeclarativebehavior.cpp
+++ b/src/declarative/util/qdeclarativebehavior.cpp
@@ -48,6 +48,7 @@
#include <qdeclarativeinfo.h>
#include <qdeclarativeproperty_p.h>
#include <qdeclarativeguard_p.h>
+#include <qdeclarativeengine_p.h>
#include <private/qobject_p.h>
@@ -57,12 +58,13 @@ class QDeclarativeBehaviorPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QDeclarativeBehavior)
public:
- QDeclarativeBehaviorPrivate() : animation(0), enabled(true) {}
+ QDeclarativeBehaviorPrivate() : animation(0), enabled(true), finalized(false) {}
QDeclarativeProperty property;
QVariant currentValue;
QDeclarativeGuard<QDeclarativeAbstractAnimation> animation;
bool enabled;
+ bool finalized;
};
/*!
@@ -158,7 +160,7 @@ void QDeclarativeBehavior::write(const QVariant &value)
{
Q_D(QDeclarativeBehavior);
qmlExecuteDeferred(this);
- if (!d->animation || !d->enabled) {
+ if (!d->animation || !d->enabled || !d->finalized) {
QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
return;
}
@@ -189,6 +191,15 @@ void QDeclarativeBehavior::setTarget(const QDeclarativeProperty &property)
d->currentValue = property.read();
if (d->animation)
d->animation->setDefaultTarget(property);
+
+ QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this));
+ engPriv->registerFinalizedParserStatusObject(this, this->metaObject()->indexOfSlot("componentFinalized()"));
+}
+
+void QDeclarativeBehavior::componentFinalized()
+{
+ Q_D(QDeclarativeBehavior);
+ d->finalized = true;
}
QT_END_NAMESPACE