diff options
3 files changed, 50 insertions, 2 deletions
diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp index 5e03480206..05cf786e7d 100644 --- a/src/qml/animations/qabstractanimationjob.cpp +++ b/src/qml/animations/qabstractanimationjob.cpp @@ -243,6 +243,7 @@ void QQmlAnimationTimer::registerRunningAnimation(QAbstractAnimationJob *animati void QQmlAnimationTimer::unregisterRunningAnimation(QAbstractAnimationJob *animation) { + unsetJobTimer(animation); if (animation->userControlDisabled()) return; @@ -307,9 +308,10 @@ QAbstractAnimationJob::~QAbstractAnimationJob() Q_ASSERT(m_state == Stopped); if (oldState == Running) { - Q_ASSERT(QQmlAnimationTimer::instance(false) == m_timer); - if (m_timer) + if (m_timer) { + Q_ASSERT(QQmlAnimationTimer::instance(false) == m_timer); m_timer->unregisterAnimation(this); + } } Q_ASSERT(!m_hasRegisteredTimer); } diff --git a/tests/auto/quick/qquickanimations/data/cleanupWhenRenderThreadStops.qml b/tests/auto/quick/qquickanimations/data/cleanupWhenRenderThreadStops.qml new file mode 100644 index 0000000000..4cfb59aeab --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/cleanupWhenRenderThreadStops.qml @@ -0,0 +1,32 @@ +//main.qml + +import QtQuick 2.12 +import QtQuick.Window 2.12 + +Item { + id: root + width: 640 + height: 480 + visible: true + property bool running : false + + Rectangle { + id: rect + anchors.fill: parent + color: "red" + + Component.onCompleted: { + anim.start() + running = true + } + } + + OpacityAnimator { + id: anim + + target: rect + from: 1 + to: 0 + duration: 20000 + } +} diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp index f373f53f1b..e2bac5ee39 100644 --- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp +++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp @@ -116,6 +116,7 @@ private slots: void fastFlickingBug(); void opacityAnimationFromZero(); void alwaysRunToEndInSequentialAnimationBug(); + void cleanupWhenRenderThreadStops(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -1998,6 +1999,19 @@ void tst_qquickanimations::alwaysRunToEndInSequentialAnimationBug() QCOMPARE(whiteRect->property("opacity").value<qreal>(),1.0); } +void tst_qquickanimations::cleanupWhenRenderThreadStops() +{ + QQuickView view(QUrl::fromLocalFile("data/cleanupWhenRenderThreadStops.qml")); + view.show(); + view.setPersistentGraphics(false); + view.setPersistentSceneGraph(false); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + QTest::qWait(50); + view.hide(); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); +} + QTEST_MAIN(tst_qquickanimations) #include "tst_qquickanimations.moc" |