Further delay animation creation in Behavior.
authorMichael Brasser <michael.brasser@nokia.com>
Thu, 22 Sep 2011 23:44:09 +0000 (09:44 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 23 Sep 2011 00:22:26 +0000 (02:22 +0200)
Previously we always created the animation on the first call to write,
regardless of whether the Behavior was enabled. Now we delay until the
animation is needed.

Change-Id: I14a319a4f045050fe6a99427b7c3804ef078d48d
Reviewed-on: http://codereview.qt-project.org/5414
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Charles Yin <charles.yin@nokia.com>
src/declarative/util/qdeclarativebehavior.cpp

index 84636e4..550b8a3 100644 (file)
@@ -175,8 +175,10 @@ void QDeclarativeBehavior::setEnabled(bool enabled)
 void QDeclarativeBehavior::write(const QVariant &value)
 {
     Q_D(QDeclarativeBehavior);
-    qmlExecuteDeferred(this);
-    if (!d->animation || !d->enabled || !d->finalized) {
+    bool bypass = !d->enabled || !d->finalized;
+    if (!bypass)
+        qmlExecuteDeferred(this);
+    if (!d->animation || bypass) {
         QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
         d->targetValue = value;
         return;