Fix segfault when creating token of opponent's card (#6144)

* Fix segfault when creating token of opponent's card

* clean up code
This commit is contained in:
RickyRister 2025-09-15 03:18:51 -07:00 committed by GitHub
parent a9cbd5a172
commit f4fbe90a72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -878,7 +878,12 @@ void PlayerActions::actCreateAnotherToken()
void PlayerActions::setLastToken(CardInfoPtr cardInfo) void PlayerActions::setLastToken(CardInfoPtr cardInfo)
{ {
if (cardInfo == nullptr || !player->getPlayerMenu()->getUtilityMenu()->createAnotherTokenActionExists()) { if (cardInfo == nullptr) {
return;
}
UtilityMenu *utilityMenu = player->getPlayerMenu()->getUtilityMenu();
if (utilityMenu == nullptr || !utilityMenu->createAnotherTokenActionExists()) {
return; return;
} }
@ -892,8 +897,7 @@ void PlayerActions::setLastToken(CardInfoPtr cardInfo)
lastTokenTableRow = TableZone::clampValidTableRow(2 - cardInfo->getTableRow()); lastTokenTableRow = TableZone::clampValidTableRow(2 - cardInfo->getTableRow());
player->getPlayerMenu()->getUtilityMenu()->setAndEnableCreateAnotherTokenAction( utilityMenu->setAndEnableCreateAnotherTokenAction(tr("C&reate another %1 token").arg(lastTokenInfo.name));
tr("C&reate another %1 token").arg(lastTokenInfo.name));
} }
void PlayerActions::actCreatePredefinedToken() void PlayerActions::actCreatePredefinedToken()