mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Prevent crashes from calling CardView.getCards and assumming non-null
This commit is contained in:
@@ -48,7 +48,7 @@ public class ZoneAction extends ForgeAction {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(final ActionEvent e) {
|
public void actionPerformed(final ActionEvent e) {
|
||||||
final Iterable<CardView> choices = this.getCardsAsIterable();
|
final Iterable<CardView> choices = this.getCardsAsIterable();
|
||||||
if (!choices.iterator().hasNext()) {
|
if (choices == null || !choices.iterator().hasNext()) {
|
||||||
GuiChoose.reveal(this.title, "no cards");
|
GuiChoose.reveal(this.title, "no cards");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -598,7 +598,13 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
private void recalculateCardPanels(final PlayerView model, final ZoneType zone) {
|
private void recalculateCardPanels(final PlayerView model, final ZoneType zone) {
|
||||||
final List<CardView> modelCopy;
|
final List<CardView> modelCopy;
|
||||||
synchronized (model) {
|
synchronized (model) {
|
||||||
modelCopy = Lists.newArrayList(model.getCards(zone));
|
Iterable<CardView> cards = model.getCards(zone);
|
||||||
|
if (cards != null) {
|
||||||
|
modelCopy = Lists.newArrayList(cards);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
modelCopy = Lists.newArrayList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<CardView> oldCards = Lists.newArrayList();
|
final List<CardView> oldCards = Lists.newArrayList();
|
||||||
@@ -620,7 +626,8 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
|
|
||||||
if (toDelete.size() == getCardPanels().size()) {
|
if (toDelete.size() == getCardPanels().size()) {
|
||||||
clear();
|
clear();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
for (final CardView card : toDelete) {
|
for (final CardView card : toDelete) {
|
||||||
removeCardPanel(getCardPanel(card.getId()));
|
removeCardPanel(getCardPanel(card.getId()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,12 +46,14 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
|||||||
clear();
|
clear();
|
||||||
|
|
||||||
CardAreaPanel newCardPanel = null;
|
CardAreaPanel newCardPanel = null;
|
||||||
for (CardView card : model) {
|
if (model != null) {
|
||||||
CardAreaPanel cardPanel = CardAreaPanel.get(card);
|
for (CardView card : model) {
|
||||||
addCardPanelToDisplayArea(cardPanel);
|
CardAreaPanel cardPanel = CardAreaPanel.get(card);
|
||||||
cardPanels.add(cardPanel);
|
addCardPanelToDisplayArea(cardPanel);
|
||||||
if (newCardPanel == null && !orderedCards.contains(card)) {
|
cardPanels.add(cardPanel);
|
||||||
newCardPanel = cardPanel;
|
if (newCardPanel == null && !orderedCards.contains(card)) {
|
||||||
|
newCardPanel = cardPanel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
revalidate();
|
revalidate();
|
||||||
|
|||||||
Reference in New Issue
Block a user