From df6143c03ae0b24f45ba65e8ba171d4e11039e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Mon, 15 Sep 2025 18:54:38 +0200 Subject: [PATCH] Also check for it in the successful branch. Took 6 minutes --- cockatrice/src/game/board/card_item.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cockatrice/src/game/board/card_item.cpp b/cockatrice/src/game/board/card_item.cpp index c5ac0cd29..db15c8f03 100644 --- a/cockatrice/src/game/board/card_item.cpp +++ b/cockatrice/src/game/board/card_item.cpp @@ -185,10 +185,14 @@ void CardItem::setAttachedTo(CardItem *_attachedTo) gridPoint.setX(-1); attachedTo = _attachedTo; if (attachedTo != nullptr) { - emit attachedTo->zone->cardAdded(this); - attachedTo->addAttachedCard(this); - if (zone != attachedTo->getZone()) { - attachedTo->getZone()->reorganizeCards(); + if (attachedTo->zone == nullptr) { + deleteLater(); + } else { + emit attachedTo->zone->cardAdded(this); + attachedTo->addAttachedCard(this); + if (zone != attachedTo->getZone()) { + attachedTo->getZone()->reorganizeCards(); + } } } else { // If the zone is being torn down, it might already be null by the time a card tries to re-attach all its