diff options
3 files changed, 35 insertions, 2 deletions
diff --git a/src/declarative/util/qdeclarativesmoothedanimation.cpp b/src/declarative/util/qdeclarativesmoothedanimation.cpp index 1e68a7a1..240bc5d6 100644 --- a/src/declarative/util/qdeclarativesmoothedanimation.cpp +++ b/src/declarative/util/qdeclarativesmoothedanimation.cpp @@ -100,10 +100,10 @@ bool QSmoothedAnimation::recalc() s = (invert? qreal(-1.0): qreal(1.0)) * s; - if (userDuration > 0 && velocity > 0) { + if (userDuration >= 0 && velocity > 0) { tf = s / velocity; if (tf > (userDuration / qreal(1000.))) tf = (userDuration / qreal(1000.)); - } else if (userDuration > 0) { + } else if (userDuration >= 0) { tf = userDuration / qreal(1000.); } else if (velocity > 0) { tf = s / velocity; diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationZeroDuration.qml b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationZeroDuration.qml new file mode 100644 index 00000000..cba1ffe5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationZeroDuration.qml @@ -0,0 +1,12 @@ +import QtQuick 1.0 + +Rectangle { + width: 300; height: 300; + Rectangle { + objectName: "theRect" + color: "red" + width: 60; height: 60; + x: 100; y: 100; + SmoothedAnimation on x { objectName: "easeX"; to: 200; duration: 0 } + } +} diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp b/tests/auto/declarative/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp index 452168a6..1d511779 100644 --- a/tests/auto/declarative/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp @@ -58,6 +58,7 @@ private slots: void simpleAnimation(); void valueSource(); void behavior(); + void zeroDuration(); private: QDeclarativeEngine engine; @@ -201,6 +202,26 @@ void tst_qdeclarativesmoothedanimation::behavior() QTRY_COMPARE(theRect->y(), qreal(200)); } +void tst_qdeclarativesmoothedanimation::zeroDuration() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimationZeroDuration.qml")); + + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect); + + QDeclarativeRectangle *theRect = rect->findChild<QDeclarativeRectangle*>("theRect"); + QVERIFY(theRect); + + QDeclarativeSmoothedAnimation *easeX = rect->findChild<QDeclarativeSmoothedAnimation*>("easeX"); + QVERIFY(easeX); + QVERIFY(easeX->isRunning()); + + QTRY_VERIFY(!easeX->isRunning()); + QTRY_COMPARE(theRect->x(), qreal(200)); +} + QTEST_MAIN(tst_qdeclarativesmoothedanimation) #include "tst_qdeclarativesmoothedanimation.moc" |