diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-06-27 10:34:45 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2020-04-02 07:11:04 +0100 |
commit | 38b3504e972281f4b79d78ad325686863fdafcd5 (patch) | |
tree | 3578019e9eff6431dab3f9d3ba36cd5f55f39df4 | |
parent | 5a2f1f4c71a71dbc01af71bdbc83ff650475f525 (diff) |
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>
(cherry picked from commit 732b63ed0cd38feebd17978abde2843eddd2b7b2)
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r-- | src/quick/util/qquickbehavior.cpp | 2 | ||||
-rw-r--r-- | tests/auto/quick/qquickbehaviors/data/delete.qml | 37 | ||||
-rw-r--r-- | tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp | 11 |
3 files changed, 49 insertions, 1 deletions
diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp index d9b13067ad..31c0ecddf6 100644 --- a/src/quick/util/qquickbehavior.cpp +++ b/src/quick/util/qquickbehavior.cpp @@ -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); } diff --git a/tests/auto/quick/qquickbehaviors/data/delete.qml b/tests/auto/quick/qquickbehaviors/data/delete.qml new file mode 100644 index 0000000000..1bf0267b84 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/delete.qml @@ -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 + } + } + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp index fa9eba095d..8a962ce240 100644 --- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp +++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp @@ -73,6 +73,7 @@ private slots: void disabledWriteWhileRunning(); void aliasedProperty(); void innerBehaviorOverwritten(); + void safeToDelete(); }; void tst_qquickbehaviors::simpleBehavior() @@ -598,6 +599,16 @@ void tst_qquickbehaviors::innerBehaviorOverwritten() QVERIFY(item->property("behaviorTriggered").toBool()); } +// 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" |