check for null zone during card item teardown (#6149)

* check for null zone during card item teardown

Took 1 hour 32 minutes


Took 24 seconds

* Also check for it in the successful branch.

Took 6 minutes

* Comment.

Took 5 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2025-09-15 20:06:20 +02:00 committed by GitHub
parent 190ab211e3
commit 9c3be1b851
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -185,13 +185,25 @@ 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 the zone is being torn down, it might already be null by the time a card tries to un-attach all its
// attached cards
if (attachedTo->zone == nullptr) {
deleteLater();
} else {
emit attachedTo->zone->cardAdded(this);
attachedTo->addAttachedCard(this);
if (zone != attachedTo->getZone()) {
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 un-attach all its
// attached cards
if (zone == nullptr) {
deleteLater();
} else {
emit zone->cardAdded(this);
}
}
if (zone != nullptr) {