diff options
3 files changed, 37 insertions, 2 deletions
diff --git a/src/declarative/util/qdeclarativetransitionmanager.cpp b/src/declarative/util/qdeclarativetransitionmanager.cpp index 0b549b7cf7..30504cb241 100644 --- a/src/declarative/util/qdeclarativetransitionmanager.cpp +++ b/src/declarative/util/qdeclarativetransitionmanager.cpp @@ -119,7 +119,7 @@ void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> & 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; @@ -139,8 +139,11 @@ void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> & // // 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) { diff --git a/tests/auto/declarative/qdeclarativestates/data/avoidFastForward.qml b/tests/auto/declarative/qdeclarativestates/data/avoidFastForward.qml new file mode 100644 index 0000000000..519befc31e --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/avoidFastForward.qml @@ -0,0 +1,17 @@ +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 } + } +} diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index e13a6c4305..165179e35d 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -149,6 +149,7 @@ private slots: void extendsBug(); void editProperties(); void QTBUG_14830(); + void avoidFastForward(); }; void tst_qdeclarativestates::initTestCase() @@ -1513,6 +1514,20 @@ void tst_qdeclarativestates::QTBUG_14830() 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" |