aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-01-21 12:31:43 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-01-21 13:37:00 +0100
commit7290f9b82ab715d4ffe1c1515d8248862dab8a3c (patch)
treefc8eb16bb514aa5201003067ccf02383fe7ee57d /tests
parente9af4fcf54046d077b6792b25e080ffdacc3f327 (diff)
Avoid memory leaks in QSequentialAnimationGroupJob test
Change-Id: Ib221f83ff80ed02f29b1dbe2767ccf63abf16738 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
index 4718eb33b4..3c6d4f739c 100644
--- a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
+++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
@@ -31,6 +31,8 @@
#include <QtQml/private/qparallelanimationgroupjob_p.h>
#include <QtQml/private/qpauseanimationjob_p.h>
+#include <memory>
+
Q_DECLARE_METATYPE(QAbstractAnimationJob::State)
Q_DECLARE_METATYPE(QAbstractAnimationJob*)
@@ -733,12 +735,13 @@ void tst_QSequentialAnimationGroupJob::restart()
sequence->addAnimationChangeListener(&seqStateChangedSpy, QAbstractAnimationJob::StateChange);
TestAnimation *anims[3];
- StateChangeListener *animsStateChanged[3];
+ QScopedPointer<StateChangeListener> animsStateChanged[3];
for (int i = 0; i < 3; i++) {
anims[i] = new TestAnimation(100);
- animsStateChanged[i] = new StateChangeListener;
- anims[i]->addAnimationChangeListener(animsStateChanged[i], QAbstractAnimationJob::StateChange);
+ animsStateChanged[i].reset(new StateChangeListener);
+ anims[i]->addAnimationChangeListener(animsStateChanged[i].data(),
+ QAbstractAnimationJob::StateChange);
}
anims[1]->setLoopCount(2);
@@ -1436,18 +1439,20 @@ void tst_QSequentialAnimationGroupJob::addRemoveAnimation()
QCOMPARE(group.currentAnimation(), anim1);
QCOMPARE(anim1->currentLoopTime(), 50);
+ std::unique_ptr<QAbstractAnimationJob> anim0Guard(anim0);
group.removeAnimation(anim0); //anim1 | anim2
QCOMPARE(group.currentLoopTime(), 50);
QCOMPARE(group.currentAnimation(), anim1);
QCOMPARE(anim1->currentLoopTime(), 50);
group.setCurrentTime(0);
- group.prependAnimation(anim0); //anim0 | anim1 | anim2
+ group.prependAnimation(anim0Guard.release()); //anim0 | anim1 | anim2
group.setCurrentTime(300);
QCOMPARE(group.currentLoopTime(), 300);
QCOMPARE(group.currentAnimation(), anim1);
QCOMPARE(anim1->currentLoopTime(), 50);
+ std::unique_ptr<QAbstractAnimationJob> anim1Guard(anim1);
group.removeAnimation(anim1); //anim0 | anim2
QCOMPARE(group.currentLoopTime(), 250);
QCOMPARE(group.currentAnimation(), anim2);