mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-25 16:13:54 -07:00
fix segfault when bottoming card in deck view (#5508)
This commit is contained in:
parent
090cc8c144
commit
b004e91aa4
1 changed files with 4 additions and 2 deletions
|
|
@ -282,7 +282,8 @@ void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
||||||
{
|
{
|
||||||
if (!isReversed) {
|
if (!isReversed) {
|
||||||
// if x is negative set it to add at end
|
// if x is negative set it to add at end
|
||||||
if (x < 0) {
|
// if x is out-of-bounds then also set it to add at the end
|
||||||
|
if (x < 0 || x >= cards.size()) {
|
||||||
x = cards.size();
|
x = cards.size();
|
||||||
}
|
}
|
||||||
cards.insert(x, card);
|
cards.insert(x, card);
|
||||||
|
|
@ -292,7 +293,8 @@ void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
||||||
int insertionIndex = x - firstId;
|
int insertionIndex = x - firstId;
|
||||||
if (insertionIndex >= 0) {
|
if (insertionIndex >= 0) {
|
||||||
// card was put into a portion of the deck that's in the view
|
// card was put into a portion of the deck that's in the view
|
||||||
cards.insert(insertionIndex, card);
|
// qMin to prevent out-of-bounds error when bottoming a card that is already in the view
|
||||||
|
cards.insert(qMin(insertionIndex, cards.size()), card);
|
||||||
} else {
|
} else {
|
||||||
// card was put into a portion of the deck that's not in the view
|
// card was put into a portion of the deck that's not in the view
|
||||||
updateCardIds(ADD_CARD);
|
updateCardIds(ADD_CARD);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue