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>
This commit is contained in:
Marc Mutz 2021-12-16 08:18:57 +01:00
parent bdaab71c68
commit dc672cf35a

View File

@ -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);