Check that animation still exists

Fixes: QTBUG-76749
Change-Id: Ie5eed240e8190a7297f71f5e40870a007e737d1d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
Fabian Kosmale 2019-06-27 10:34:45 +02:00 committed by Simon Hausmann
parent 9834ac5604
commit 732b63ed0c
3 changed files with 49 additions and 1 deletions

View File

@ -143,7 +143,7 @@ void QQuickBehavior::setAnimation(QQuickAbstractAnimation *animation)
void QQuickBehaviorPrivate::animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState,QAbstractAnimationJob::State)
{
if (!blockRunningChanged)
if (!blockRunningChanged && animation)
animation->notifyRunningChanged(newState == QAbstractAnimationJob::Running);
}

View File

@ -0,0 +1,37 @@
import QtQuick 2.12
Item {
visible: true
width: 640
height: 480
Component.onCompleted: {
myLoader.active = false
}
Loader {
id: myLoader
active: true
sourceComponent: Item {
width: 100
height: 100
id: myPopup
NumberAnimation {
id: anim
}
Rectangle {
color: "black"
Component.onCompleted: {
opacity = 20
}
Behavior on opacity {
animation: anim
}
}
}
}
}

View File

@ -74,6 +74,7 @@ private slots:
void aliasedProperty();
void innerBehaviorOverwritten();
void oneWay();
void safeToDelete();
};
void tst_qquickbehaviors::simpleBehavior()
@ -647,6 +648,16 @@ void tst_qquickbehaviors::oneWay()
QCOMPARE(myAnimation->isRunning(), false);
}
// QTBUG-76749
void tst_qquickbehaviors::safeToDelete()
{
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("delete.qml"));
QVERIFY(c.create());
}
QTEST_MAIN(tst_qquickbehaviors)
#include "tst_qquickbehaviors.moc"