mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-19 13:23:55 -07:00
crash fix
This commit is contained in:
parent
8bd8b6218e
commit
6e567d5b2f
6 changed files with 34 additions and 26 deletions
|
|
@ -106,19 +106,35 @@ CardItem::CardItem(Player *_owner, const QString &_name, int _cardid, QGraphicsI
|
|||
|
||||
CardItem::~CardItem()
|
||||
{
|
||||
if (owner->getCardMenu() == cardMenu)
|
||||
owner->setCardMenu(0);
|
||||
prepareDelete();
|
||||
deleteDragItem();
|
||||
}
|
||||
|
||||
void CardItem::prepareDelete()
|
||||
{
|
||||
if (owner) {
|
||||
if (owner->getCardMenu() == cardMenu)
|
||||
owner->setCardMenu(0);
|
||||
owner = 0;
|
||||
}
|
||||
delete cardMenu;
|
||||
cardMenu = 0;
|
||||
|
||||
while (!attachedCards.isEmpty()) {
|
||||
attachedCards.first()->setZone(0); // so that it won't try to call reorganizeCards()
|
||||
attachedCards.first()->setAttachedTo(0);
|
||||
}
|
||||
|
||||
if (attachedTo)
|
||||
if (attachedTo) {
|
||||
attachedTo->removeAttachedCard(this);
|
||||
attachedTo = 0;
|
||||
}
|
||||
}
|
||||
|
||||
deleteDragItem();
|
||||
void CardItem::deleteLater()
|
||||
{
|
||||
prepareDelete();
|
||||
AbstractCardItem::deleteLater();
|
||||
}
|
||||
|
||||
void CardItem::retranslateUi()
|
||||
|
|
@ -236,10 +252,12 @@ void CardItem::setAttachedTo(CardItem *_attachedTo)
|
|||
gridPoint.setX(-1);
|
||||
attachedTo = _attachedTo;
|
||||
if (attachedTo) {
|
||||
setParentItem(attachedTo->getZone());
|
||||
attachedTo->addAttachedCard(this);
|
||||
if (zone != attachedTo->getZone())
|
||||
attachedTo->getZone()->reorganizeCards();
|
||||
}
|
||||
} else
|
||||
setParentItem(zone);
|
||||
|
||||
if (zone)
|
||||
zone->reorganizeCards();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue