diff options
-rw-r--r-- | src/qml/animations/qanimationgroupjob.cpp | 10 | ||||
-rw-r--r-- | tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp | 7 |
2 files changed, 8 insertions, 9 deletions
diff --git a/src/qml/animations/qanimationgroupjob.cpp b/src/qml/animations/qanimationgroupjob.cpp index 344791fd83..66599561fc 100644 --- a/src/qml/animations/qanimationgroupjob.cpp +++ b/src/qml/animations/qanimationgroupjob.cpp @@ -120,13 +120,9 @@ void QAnimationGroupJob::removeAnimation(QAbstractAnimationJob *animation) void QAnimationGroupJob::clear() { - QAbstractAnimationJob *child = firstChild(); - QAbstractAnimationJob *nextSibling = nullptr; - while (child != nullptr) { - child->m_group = nullptr; - nextSibling = child->nextSibling(); - delete child; - child = nextSibling; + while (QAbstractAnimationJob *child = firstChild()) { + removeAnimation(child); + delete child; } m_firstChild = nullptr; m_lastChild = nullptr; diff --git a/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp index 974357dc8e..6bd8c2a2e0 100644 --- a/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp +++ b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp @@ -261,15 +261,18 @@ void tst_QAnimationGroupJob::addChildTwice() { QAbstractAnimationJob *subGroup; QAbstractAnimationJob *subGroup2; - QAnimationGroupJob *parent = new QSequentialAnimationGroupJob(); + auto *parent = new QSequentialAnimationGroupJob(); subGroup = new QAbstractAnimationJob; parent->appendAnimation(subGroup); parent->appendAnimation(subGroup); - QVERIFY(parent->firstChild() && !parent->firstChild()->nextSibling()); + QVERIFY(parent->firstChild()); + QVERIFY(!parent->firstChild()->nextSibling()); + QVERIFY(!parent->firstChild()->previousSibling()); parent->clear(); + QCOMPARE(parent->currentAnimation(), nullptr); QVERIFY(!parent->firstChild()); // adding the same item twice to a group will remove the item from its current position |