Fast-forwarding is only required when we are animating a state change.
Task-number: QTBUG-16662
Change-Id: I20e1a056cb3268b92b606be34809bcd0e2bfb898
Reviewed-on: http://codereview.qt-project.org/4390
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Charles Yin <charles.yin@nokia.com>
cancel();
QDeclarativeStateOperation::ActionList applyList = list;
- // Determine which actions are binding changes.
+ // Determine which actions are binding changes and disable any current bindings
foreach(const QDeclarativeAction &action, applyList) {
if (action.toBinding)
d->bindingsList << action;
//
// This doesn't catch everything, and it might be a little fragile in
// some cases - but whatcha going to do?
+ //
+ // Note that we only fast forward if both a transition and bindings are
+ // present, as it is unneccessary (and potentially expensive) otherwise.
- if (!d->bindingsList.isEmpty()) {
+ if (transition && !d->bindingsList.isEmpty()) {
// Apply all the property and binding changes
for (int ii = 0; ii < applyList.size(); ++ii) {
--- /dev/null
+import QtQuick 2.0
+
+Rectangle {
+ id: rect
+ width: 200
+ height: 200
+
+ property int updateCount: 0
+ onColorChanged: updateCount++
+
+ property color aColor: "green"
+
+ states: State {
+ name: "a"
+ PropertyChanges { target: rect; color: aColor }
+ }
+}
void extendsBug();
void editProperties();
void QTBUG_14830();
+ void avoidFastForward();
};
void tst_qdeclarativestates::initTestCase()
QCOMPARE(item->width(), qreal(171));
}
+void tst_qdeclarativestates::avoidFastForward()
+{
+ QDeclarativeEngine engine;
+
+ //shouldn't fast forward if there isn't a transition
+ QDeclarativeComponent c(&engine, SRCDIR "/data/avoidFastForward.qml");
+ QSGRectangle *rect = qobject_cast<QSGRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect);
+ rectPrivate->setState("a");
+ QCOMPARE(rect->property("updateCount").toInt(), 1);
+}
+
QTEST_MAIN(tst_qdeclarativestates)
#include "tst_qdeclarativestates.moc"