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