From 7b47b5992f8ebbe1a1a3157f27120a9b27a49ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Mon, 15 Sep 2025 19:11:56 +0200 Subject: [PATCH] Animation safety. Took 12 minutes --- cockatrice/src/game/board/card_item.cpp | 2 +- cockatrice/src/game/game_scene.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/game/board/card_item.cpp b/cockatrice/src/game/board/card_item.cpp index afcd38789..382803b96 100644 --- a/cockatrice/src/game/board/card_item.cpp +++ b/cockatrice/src/game/board/card_item.cpp @@ -54,9 +54,9 @@ void CardItem::prepareDelete() void CardItem::deleteLater() { - prepareDelete(); if (scene()) static_cast(scene())->unregisterAnimationItem(this); + prepareDelete(); AbstractCardItem::deleteLater(); } diff --git a/cockatrice/src/game/game_scene.cpp b/cockatrice/src/game/game_scene.cpp index 1494661d7..df2b67664 100644 --- a/cockatrice/src/game/game_scene.cpp +++ b/cockatrice/src/game/game_scene.cpp @@ -304,8 +304,11 @@ void GameScene::timerEvent(QTimerEvent * /*event*/) QMutableSetIterator i(cardsToAnimate); while (i.hasNext()) { i.next(); - if (!i.value()->animationEvent()) + if (i.value() == nullptr) { i.remove(); + } else if (!i.value()->animationEvent()) { + i.remove(); + } } if (cardsToAnimate.isEmpty()) animationTimer->stop();