From af4672ad3ed5b549ac78488e4e0aa9d2cde04ce9 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 22 Apr 2015 13:21:59 +0100 Subject: [PATCH] JAL-1690 fix NPE on Cancel when not in split frame --- src/jalview/gui/FontChooser.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index 5e13781..381fbe3 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -94,8 +94,10 @@ public class FontChooser extends GFontChooser * Enable 'scale protein as cDNA' in a SplitFrame view. The selection is * stored in the ViewStyle of both dna and protein Viewport */ + scaleAsCdna.setEnabled(false); if (ap.av.getCodingComplement() != null) { + scaleAsCdna.setEnabled(true); scaleAsCdna.setVisible(true); scaleAsCdna.setSelected(ap.av.isScaleProteinAsCdna()); } @@ -243,15 +245,19 @@ public class FontChooser extends GFontChooser .getStringBounds("I", getGraphics()).getWidth(); if (mw < 1 || iw < 1) { - fontName.setSelectedItem(lastSelected.getName()); - fontStyle.setSelectedIndex(lastSelStyle); - fontSize.setSelectedItem(lastSelSize); - monospaced.setSelected(lastSelMono); JOptionPane .showInternalMessageDialog( this, MessageManager.getString("label.font_doesnt_have_letters_defined"), MessageManager.getString("label.invalid_font"), JOptionPane.WARNING_MESSAGE); + /* + * Restore previous values - size first to avoid recursive calls to this + * point! + */ + fontSize.setSelectedItem(lastSelSize); + fontName.setSelectedItem(lastSelected.getName()); + fontStyle.setSelectedIndex(lastSelStyle); + monospaced.setSelected(lastSelMono); return; } if (tp != null) -- 1.7.10.2