Add a guard in case the printing info is empty for a related card. (#6087)

Took 4 hours 19 minutes

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2025-08-24 05:34:41 +02:00 committed by GitHub
parent 268559d8de
commit ba794c2b60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 4 deletions

View file

@ -460,8 +460,21 @@ bool CardDatabase::isPreferredPrinting(const CardRef &cardRef) const
ExactCard CardDatabase::getCardFromSameSet(const QString &cardName, const PrintingInfo &otherPrinting) const
{
// The source card does not have a printing defined, which means we can't get a card from the same set.
if (otherPrinting == PrintingInfo()) {
return getCard({cardName});
}
// The source card does have a printing defined, which means we can attempt to get a card from the same set.
PrintingInfo relatedPrinting = getSpecificPrinting(cardName, otherPrinting.getSet()->getCorrectedShortName(), "");
return ExactCard(guessCard({cardName}).getCardPtr(), relatedPrinting);
ExactCard relatedCard = ExactCard(guessCard({cardName}).getCardPtr(), relatedPrinting);
// We didn't find a card from the same set, just try to find any card with the same name.
if (!relatedCard) {
return getCard({cardName});
}
return relatedCard;
}
void CardDatabase::refreshCachedReverseRelatedCards()