Prevent crashes from calling CardView.getCards and assumming non-null

This commit is contained in:
drdev
2014-10-10 16:31:05 +00:00
parent f74f438765
commit 033cf1701a
3 changed files with 18 additions and 9 deletions

View File

@@ -48,7 +48,7 @@ public class ZoneAction extends ForgeAction {
@Override
public void actionPerformed(final ActionEvent e) {
final Iterable<CardView> choices = this.getCardsAsIterable();
if (!choices.iterator().hasNext()) {
if (choices == null || !choices.iterator().hasNext()) {
GuiChoose.reveal(this.title, "no cards");
return;
}

View File

@@ -598,7 +598,13 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
private void recalculateCardPanels(final PlayerView model, final ZoneType zone) {
final List<CardView> modelCopy;
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();
@@ -620,7 +626,8 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
if (toDelete.size() == getCardPanels().size()) {
clear();
} else {
}
else {
for (final CardView card : toDelete) {
removeCardPanel(getCardPanel(card.getId()));
}