Fix regression from #4281 which caused crash with QList and GCC race time (#4341)

This commit is contained in:
Zach H 2021-05-09 14:50:48 -04:00 committed by GitHub
parent b9c4b496e4
commit 8fb561b4c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -575,15 +575,19 @@ void Server_Game::unattachCards(GameEventStorage &ges, Server_Player *player)
{
QMutexLocker locker(&gameMutex);
QMapIterator<QString, Server_CardZone *> zoneIterator(player->getZones());
for (Server_CardZone *zone : player->getZones()) {
for (Server_Card *card : zone->getCards()) {
for (auto zone : player->getZones()) {
for (auto card : zone->getCards()) {
if (card == nullptr) {
continue;
}
const auto &attachedCardsBase = card->getAttachedCards();
if (attachedCardsBase.isEmpty()) {
continue;
}
// Make a copy of the list because the original one gets modified during the loop
QList<Server_Card *> attachedCards = card->getAttachedCards();
QList<Server_Card *> attachedCards = {attachedCardsBase};
for (Server_Card *attachedCard : attachedCards) {
attachedCard->getZone()->getPlayer()->unattachCard(ges, attachedCard);
}