From 4938984f9a779192264757a06e6ca555fc8f5e91 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 3 Feb 2021 14:24:14 +0100 Subject: Use a QDoubleEndedList for the children of animation group jobs This way it's fundamentally impossible to add the same animation job to two different group jobs. The pointers are not exposed anymore and no one can re-order the jobs. Task-number: QTBUG-90401 Change-Id: Iebff4b64960c853915dd32714acd144fc5cdc00d Reviewed-by: Fabian Kosmale --- .../qanimationgroupjob/tst_qanimationgroupjob.cpp | 17 +++++++++-------- .../tst_qparallelanimationgroupjob.cpp | 9 +++------ .../tst_qsequentialanimationgroupjob.cpp | 15 ++++++--------- .../quick/qquickanimations/tst_qquickanimations.cpp | 2 +- 4 files changed, 19 insertions(+), 24 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp index 6bd8c2a2e0..ceb8cc707f 100644 --- a/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp +++ b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp @@ -266,14 +266,15 @@ void tst_QAnimationGroupJob::addChildTwice() subGroup = new QAbstractAnimationJob; parent->appendAnimation(subGroup); parent->appendAnimation(subGroup); - QVERIFY(parent->firstChild()); - QVERIFY(!parent->firstChild()->nextSibling()); - QVERIFY(!parent->firstChild()->previousSibling()); + QVERIFY(!parent->children()->isEmpty()); + QCOMPARE(parent->children()->count(), 1); + QVERIFY(!parent->children()->next(parent->children()->first())); + QVERIFY(!parent->children()->prev(parent->children()->last())); parent->clear(); QCOMPARE(parent->currentAnimation(), nullptr); - QVERIFY(!parent->firstChild()); + QVERIFY(parent->children()->isEmpty()); // adding the same item twice to a group will remove the item from its current position // and append it to the end @@ -282,13 +283,13 @@ void tst_QAnimationGroupJob::addChildTwice() subGroup2 = new QAbstractAnimationJob; parent->appendAnimation(subGroup2); - QCOMPARE(parent->firstChild(), subGroup); - QCOMPARE(parent->lastChild(), subGroup2); + QCOMPARE(parent->children()->first(), subGroup); + QCOMPARE(parent->children()->last(), subGroup2); parent->appendAnimation(subGroup); - QCOMPARE(parent->firstChild(), subGroup2); - QCOMPARE(parent->lastChild(), subGroup); + QCOMPARE(parent->children()->first(), subGroup2); + QCOMPARE(parent->children()->last(), subGroup); delete parent; } diff --git a/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp index 8c4c461813..a22c94e4c4 100644 --- a/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp +++ b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp @@ -321,14 +321,11 @@ void tst_QParallelAnimationGroupJob::clearGroup() group.appendAnimation(new QParallelAnimationGroupJob); } - int count = 0; - for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling()) - ++count; - QCOMPARE(count, animationCount); + QCOMPARE(group.children()->count(), animationCount); group.clear(); - QVERIFY(!group.firstChild() && !group.lastChild()); + QVERIFY(group.children()->isEmpty()); QCOMPARE(group.currentLoopTime(), 0); } @@ -435,7 +432,7 @@ void tst_QParallelAnimationGroupJob::deleteChildrenWithRunningGroup() QTRY_VERIFY(group.currentLoopTime() > 0); delete anim1; - QVERIFY(!group.firstChild()); + QVERIFY(group.children()->isEmpty()); QCOMPARE(group.duration(), 0); QCOMPARE(group.state(), QAnimationGroupJob::Stopped); QCOMPARE(group.currentLoopTime(), 0); //that's the invariant diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp index 2712ccde67..e8872ebc58 100644 --- a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp +++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp @@ -933,14 +933,11 @@ void tst_QSequentialAnimationGroupJob::clearGroup() subGroup->appendAnimation(new QPauseAnimationJob(10)); } - int count = 0; - for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling()) - ++count; - QCOMPARE(count, animationCount); + QCOMPARE(group.children()->count(), animationCount); group.clear(); - QVERIFY(!group.firstChild() && !group.lastChild()); + QVERIFY(group.children()->isEmpty()); QCOMPARE(group.currentLoopTime(), 0); } @@ -1131,7 +1128,7 @@ void tst_QSequentialAnimationGroupJob::deleteChildrenWithRunningGroup() QTRY_VERIFY(group.currentLoopTime() > 0); delete anim1; - QVERIFY(!group.firstChild()); + QVERIFY(group.children()->isEmpty()); QCOMPARE(group.duration(), 0); QCOMPARE(group.state(), QAnimationGroupJob::Stopped); QCOMPARE(group.currentLoopTime(), 0); //that's the invariant @@ -1568,12 +1565,12 @@ void tst_QSequentialAnimationGroupJob::clear() TestAnimation *anim2 = new TestAnimation; group.appendAnimation(anim2); - QCOMPARE(group.firstChild(), anim1); - QCOMPARE(group.lastChild(), anim2); + QCOMPARE(group.children()->first(), anim1); + QCOMPARE(group.children()->last(), anim2); group.start(); QTest::qWait(anim1->duration() + 100); - QTRY_VERIFY(!group.firstChild()); + QTRY_VERIFY(group.children()->isEmpty()); QCOMPARE(group.state(), QAbstractAnimationJob::Stopped); QCOMPARE(group.currentLoopTime(), 0); diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp index fe366d0f34..f903256d49 100644 --- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp +++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp @@ -1543,7 +1543,7 @@ void tst_qquickanimations::loopingBug() QVERIFY(anim != nullptr); QCOMPARE(anim->qtAnimation()->totalDuration(), 300); QCOMPARE(anim->isRunning(), true); - QTRY_COMPARE(static_cast(anim->qtAnimation())->firstChild()->currentLoop(), 2); + QTRY_COMPARE(static_cast(anim->qtAnimation())->children()->first()->currentLoop(), 2); QTRY_COMPARE(anim->isRunning(), false); QQuickRectangle *rect = obj->findChild(); -- cgit v1.2.3