From dc672cf35ab693a5505f704d93d4cf4ea2c848c7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 16 Dec 2021 08:18:57 +0100 Subject: [PATCH] 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. Pick-to: 6.3 6.2 5.15 Change-Id: Ia53d6f6e467f1d2598a7c50efcdf3a3732fe54df Reviewed-by: Fabian Kosmale --- .../tst_qpropertyanimation.cpp | 21 +++++++++---------- 1 file 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 5612e2ce71..88bfe0dc9f 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -291,16 +291,16 @@ void tst_QPropertyAnimation::statesAndSignals_data() void tst_QPropertyAnimation::statesAndSignals() { QFETCH(bool, uncontrolled); - QPropertyAnimation *anim; + std::unique_ptr anim; if (uncontrolled) - anim = new UncontrolledAnimation; + anim = std::make_unique(); else - anim = new DummyPropertyAnimation; + anim = std::make_unique(); 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()); @@ -371,8 +371,6 @@ void tst_QPropertyAnimation::statesAndSignals() QCOMPARE(runningSpy.count(), 1); // anim has stopped QCOMPARE(finishedSpy.count(), 2); QCOMPARE(anim->currentLoopTime(), 100); - - delete anim; } } @@ -461,7 +459,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); @@ -1336,8 +1335,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);