summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2021-12-16 08:18:57 +0100
committerMarc Mutz <marc.mutz@qt.io>2021-12-18 10:38:21 +0100
commitdc672cf35ab693a5505f704d93d4cf4ea2c848c7 (patch)
tree74630face79a7fde738c4ea7fbfd45aa5a9e0505 /tests/auto
parentbdaab71c6890855e46d1856ca9e6398af47117a3 (diff)
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 <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp21
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 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<QPropertyAnimation> anim;
if (uncontrolled)
- anim = new UncontrolledAnimation;
+ anim = std::make_unique<UncontrolledAnimation>();
else
- anim = new DummyPropertyAnimation;
+ anim = std::make_unique<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());
@@ -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);