diff options
author | Marc Mutz <marc.mutz@qt.io> | 2021-12-16 08:18:57 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2021-12-19 07:30:39 +0000 |
commit | 788392e106e05ad54f1719d77886d5e7ff23af8e (patch) | |
tree | a6fdce0b6bda27954add6b22600c336b2c79fde0 /tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp | |
parent | 9311e24a0a3bdc0964add64389a09e061568b6df (diff) | |
download | qtbase-788392e106e05ad54f1719d77886d5e7ff23af8e.tar.gz |
tst_QPropertyAnimation: fix leaks occurring under normal operation
Tests were leaking objects even if all tests passed. In two cases,
there just wasn't a delete at all, in a third, the existing delete
wasn't reached because of a QSKIP.
tst_QPropertyAnimation is now, locally, LSan-clean.
Change-Id: Ia53d6f6e467f1d2598a7c50efcdf3a3732fe54df
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit dc672cf35ab693a5505f704d93d4cf4ea2c848c7)
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp')
-rw-r--r-- | tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index a538ac6fc7..b3f72e3b49 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -286,16 +286,16 @@ void tst_QPropertyAnimation::statesAndSignals_data() void tst_QPropertyAnimation::statesAndSignals() { QFETCH(bool, uncontrolled); - QPropertyAnimation *anim; + std::unique_ptr<QPropertyAnimation> anim; if (uncontrolled) - anim = new UncontrolledAnimation; + anim.reset(new UncontrolledAnimation); else - anim = new DummyPropertyAnimation; + anim.reset(new DummyPropertyAnimation); anim->setDuration(100); - QSignalSpy finishedSpy(anim, &QPropertyAnimation::finished); - QSignalSpy runningSpy(anim, &QPropertyAnimation::stateChanged); - QSignalSpy currentLoopSpy(anim, &QPropertyAnimation::currentLoopChanged); + QSignalSpy finishedSpy(anim.get(), &QPropertyAnimation::finished); + QSignalSpy runningSpy(anim.get(), &QPropertyAnimation::stateChanged); + QSignalSpy currentLoopSpy(anim.get(), &QPropertyAnimation::currentLoopChanged); QVERIFY(finishedSpy.isValid()); QVERIFY(runningSpy.isValid()); @@ -366,8 +366,6 @@ void tst_QPropertyAnimation::statesAndSignals() QCOMPARE(runningSpy.count(), 1); // anim has stopped QCOMPARE(finishedSpy.count(), 2); QCOMPARE(anim->currentLoopTime(), 100); - - delete anim; } } @@ -456,7 +454,8 @@ void tst_QPropertyAnimation::deletion3() { //test that the stopped signal is emit when the animation is destroyed TestAnimationDriver timeDriver; - QObject *object = new QWidget; + QWidget w; + QObject *object = &w; QPropertyAnimation *anim = new QPropertyAnimation(object,"minimumWidth"); anim->setStartValue(10); anim->setEndValue(20); @@ -1331,8 +1330,8 @@ void tst_QPropertyAnimation::totalDuration() void tst_QPropertyAnimation::zeroLoopCount() { - DummyPropertyAnimation* anim; - anim = new DummyPropertyAnimation; + DummyPropertyAnimation animation; + auto *anim = &animation; anim->setStartValue(0); anim->setDuration(20); anim->setLoopCount(0); |