From b8e4975c7a274f7bd1dd1fa20016c34c62045a04 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 11 Jul 2018 13:25:42 +0200 Subject: [Quick] Make sure an transition instance is stopped when replaced When a running transition does not finish of natural causes (reached the end state due to e.g. the timer finishing), it can happen that it will never be marked as finished. Specifically, when an transition is running (e.g. an add animation for a ListView), and that transition is replaced by another transition (a displace transition, because another item got added to the ListView before the add transition was finished), the first animation was never marked as stopped. The effect was that the running property would stay "true" for forever. Task-number: QTBUG-38099 Change-Id: Icbcc732f787ff23c72d843f1ecaa86a2cc9c75ec Reviewed-by: Simon Hausmann --- .../qquickanimations/tst_qquickanimations.cpp | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests/auto/quick/qquickanimations/tst_qquickanimations.cpp') diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp index 3cfe03a376..0f095774e8 100644 --- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp +++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include #include @@ -106,6 +108,7 @@ private slots: void pathLineUnspecifiedXYBug(); void unsetAnimatorProxyJobWindow(); void finished(); + void replacingTransitions(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -1686,6 +1689,40 @@ void tst_qquickanimations::finished() } } +void tst_qquickanimations::replacingTransitions() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("replacingTransitions.qml")); + QScopedPointer rect(qobject_cast(c.create())); + if (!c.errors().isEmpty()) + qDebug() << c.errorString(); + QVERIFY(rect); + + QQmlTimer *addTimer = rect->property("addTimer").value(); + QVERIFY(addTimer); + QCOMPARE(addTimer->isRunning(), false); + + QQuickTransition *addTrans = rect->property("addTransition").value(); + QVERIFY(addTrans); + QCOMPARE(addTrans->running(), false); + + QQuickTransition *displaceTrans = rect->property("displaceTransition").value(); + QVERIFY(displaceTrans); + QCOMPARE(displaceTrans->running(), false); + + QQmlListModel *model = rect->property("model").value(); + QVERIFY(model); + QCOMPARE(model->count(), 0); + + addTimer->start(); + QTest::qWait(1000 + 1000 + 10000); + + QTRY_COMPARE(addTimer->isRunning(), false); + QTRY_COMPARE(addTrans->running(), false); + QTRY_COMPARE(displaceTrans->running(), false); + QCOMPARE(model->count(), 3); +} + QTEST_MAIN(tst_qquickanimations) #include "tst_qquickanimations.moc" -- cgit v1.2.3