mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 00:04:48 -07:00
better null check (#3036)
This commit is contained in:
parent
55029b6b68
commit
261d3ac591
3 changed files with 29 additions and 11 deletions
|
|
@ -31,12 +31,13 @@ void CardZone::retranslateUi()
|
|||
|
||||
void CardZone::clearContents()
|
||||
{
|
||||
for (int i = 0; i < cards.size(); i++) {
|
||||
for (int i = 0; i < cards.size(); i++)
|
||||
{
|
||||
// If an incorrectly implemented server doesn't return attached cards to whom they belong before dropping a player,
|
||||
// we have to return them to avoid a crash.
|
||||
const QList<CardItem *> &attachedCards = cards[i]->getAttachedCards();
|
||||
for (int j = 0; j < attachedCards.size(); ++j)
|
||||
attachedCards[j]->setParentItem(attachedCards[j]->getZone());
|
||||
for (auto attachedCard : attachedCards)
|
||||
attachedCard->setParentItem(attachedCard->getZone());
|
||||
|
||||
player->deleteCard(cards.at(i));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue