From 184901c19c99c997220029a96f1de41770d31397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Mon, 15 Sep 2025 18:48:08 +0200 Subject: [PATCH] check for null zone during card item teardown Took 1 hour 32 minutes Took 24 seconds --- cockatrice/src/game/board/card_item.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/game/board/card_item.cpp b/cockatrice/src/game/board/card_item.cpp index afcd38789..c5ac0cd29 100644 --- a/cockatrice/src/game/board/card_item.cpp +++ b/cockatrice/src/game/board/card_item.cpp @@ -191,7 +191,13 @@ void CardItem::setAttachedTo(CardItem *_attachedTo) attachedTo->getZone()->reorganizeCards(); } } else { - emit zone->cardAdded(this); + // If the zone is being torn down, it might already be null by the time a card tries to re-attach all its + // attached cards + if (zone == nullptr) { + deleteLater(); + } else { + emit zone->cardAdded(this); + } } if (zone != nullptr) {