Also check for it in the successful branch.

Took 6 minutes
This commit is contained in:
Lukas Brübach 2025-09-15 18:54:38 +02:00
parent 184901c19c
commit df6143c03a

View file

@ -185,11 +185,15 @@ void CardItem::setAttachedTo(CardItem *_attachedTo)
gridPoint.setX(-1); gridPoint.setX(-1);
attachedTo = _attachedTo; attachedTo = _attachedTo;
if (attachedTo != nullptr) { if (attachedTo != nullptr) {
if (attachedTo->zone == nullptr) {
deleteLater();
} else {
emit attachedTo->zone->cardAdded(this); emit attachedTo->zone->cardAdded(this);
attachedTo->addAttachedCard(this); attachedTo->addAttachedCard(this);
if (zone != attachedTo->getZone()) { if (zone != attachedTo->getZone()) {
attachedTo->getZone()->reorganizeCards(); attachedTo->getZone()->reorganizeCards();
} }
}
} else { } else {
// If the zone is being torn down, it might already be null by the time a card tries to re-attach all its // 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 // attached cards