Merge branch 'fixCrash' into 'master'

Fix desktop GUI crash

Closes #950

See merge request core-developers/forge!3625
This commit is contained in:
Sol
2021-01-23 15:14:59 +00:00

View File

@@ -28,6 +28,7 @@ import forge.util.Lang;
import forge.util.Localizer; import forge.util.Localizer;
import forge.util.NameGenerator; import forge.util.NameGenerator;
import forge.util.gui.SOptionPane; import forge.util.gui.SOptionPane;
import forge.view.FView;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import javax.swing.*; import javax.swing.*;
@@ -517,6 +518,11 @@ public class VLobby implements ILobbyView {
} }
private void selectMainDeck(final int playerIndex) { private void selectMainDeck(final int playerIndex) {
// not fully done loading yet, avoid any changes
if (FView.SINGLETON_INSTANCE.getSplash() != null) {
return;
}
if (hasVariant(GameType.Commander) || hasVariant(GameType.Oathbreaker) || hasVariant(GameType.TinyLeaders) || hasVariant(GameType.Brawl)) { if (hasVariant(GameType.Commander) || hasVariant(GameType.Oathbreaker) || hasVariant(GameType.TinyLeaders) || hasVariant(GameType.Brawl)) {
// These game types use specific deck panel // These game types use specific deck panel
return; return;
@@ -524,6 +530,10 @@ public class VLobby implements ILobbyView {
final FDeckChooser mainChooser = getDeckChooser(playerIndex); final FDeckChooser mainChooser = getDeckChooser(playerIndex);
final DeckType type = mainChooser.getSelectedDeckType(); final DeckType type = mainChooser.getSelectedDeckType();
final Deck deck = mainChooser.getDeck(); final Deck deck = mainChooser.getDeck();
// something went wrong, clear selection to prevent error loop
if (deck == null) {
mainChooser.getLstDecks().setSelectedIndex(0);
}
final Collection<DeckProxy> selectedDecks = mainChooser.getLstDecks().getSelectedItems(); final Collection<DeckProxy> selectedDecks = mainChooser.getLstDecks().getSelectedItems();
if (playerIndex < activePlayersNum && lobby.mayEdit(playerIndex)) { if (playerIndex < activePlayersNum && lobby.mayEdit(playerIndex)) {
final String text = type.toString() + ": " + Lang.joinHomogenous(selectedDecks, DeckProxy.FN_GET_NAME); final String text = type.toString() + ": " + Lang.joinHomogenous(selectedDecks, DeckProxy.FN_GET_NAME);