Report correct state change when destroying QAbstractAnimation
Change-Id: Ibe5310e20268d1baa5b329a4d02a3dc38d875008 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
25eb0408a6
commit
7940791f47
@ -1061,7 +1061,7 @@ QAbstractAnimation::~QAbstractAnimation()
|
||||
if (d->state != Stopped) {
|
||||
QAbstractAnimation::State oldState = d->state;
|
||||
d->state = Stopped;
|
||||
emit stateChanged(oldState, d->state);
|
||||
emit stateChanged(d->state, oldState);
|
||||
if (oldState == QAbstractAnimation::Running)
|
||||
QAnimationTimer::unregisterAnimation(this);
|
||||
}
|
||||
|
@ -83,6 +83,21 @@ void tst_QAbstractAnimation::destruction()
|
||||
{
|
||||
TestableQAbstractAnimation *anim = new TestableQAbstractAnimation;
|
||||
delete anim;
|
||||
|
||||
// Animations should stop when deleted
|
||||
auto *stopWhenDeleted = new TestableQAbstractAnimation;
|
||||
QAbstractAnimation::State lastOldState, lastNewState;
|
||||
QObject::connect(stopWhenDeleted, &QAbstractAnimation::stateChanged,
|
||||
[&](QAbstractAnimation::State newState, QAbstractAnimation::State oldState) {
|
||||
lastNewState = newState;
|
||||
lastOldState = oldState;
|
||||
});
|
||||
stopWhenDeleted->start();
|
||||
QCOMPARE(lastOldState, QAbstractAnimation::Stopped);
|
||||
QCOMPARE(lastNewState, QAbstractAnimation::Running);
|
||||
delete stopWhenDeleted;
|
||||
QCOMPARE(lastOldState, QAbstractAnimation::Running);
|
||||
QCOMPARE(lastNewState, QAbstractAnimation::Stopped);
|
||||
}
|
||||
|
||||
void tst_QAbstractAnimation::currentLoop()
|
||||
|
Loading…
Reference in New Issue
Block a user