From 51ff82459bf98489783edb76a9f2c983d8416803 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 30 Jul 2019 14:08:01 +0100 Subject: [PATCH] JAL-3364 more careful save/restore of preferences --- src/jalview/gui/AlignmentPanel.java | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index b77f9db..cd31bed 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -1211,8 +1211,7 @@ public class AlignmentPanel extends GAlignmentPanel implements * split frame with 'protein scaled to codons' and 'auto id width' */ - final boolean autoIdWidth = Cache.getDefault("FIGURE_AUTOIDWIDTH", - false); + final String autoIdWidth = Cache.getProperty("FIGURE_AUTOIDWIDTH"); final Integer fixedIdWidth = Cache .getIntegerProperty("FIGURE_FIXEDIDWIDTH"); @@ -1234,7 +1233,7 @@ public class AlignmentPanel extends GAlignmentPanel implements complement = ((AlignViewport) av.getCodingComplement()) .getAlignPanel(); dim2 = complement.getAlignmentDimension(); - if (autoIdWidth && av.isScaleProteinAsCdna()) + if (Boolean.valueOf(autoIdWidth) && av.isScaleProteinAsCdna()) { int w1 = this.getVisibleIdWidth(false); int w2 = complement.getVisibleIdWidth(false); @@ -1306,10 +1305,23 @@ public class AlignmentPanel extends GAlignmentPanel implements /* * restore preference settings in case they were fudged */ - Cache.setProperty("FIGURE_AUTOIDWIDTH", - String.valueOf(autoIdWidth)); - Cache.setProperty("FIGURE_FIXEDIDWIDTH", - String.valueOf(fixedIdWidth)); + if (autoIdWidth == null) + { + Cache.removeProperty("FIGURE_AUTOIDWIDTH"); + } + else + { + Cache.setProperty("FIGURE_AUTOIDWIDTH", autoIdWidth); + } + if (fixedIdWidth == null) + { + Cache.removeProperty("FIGURE_FIXEDIDWIDTH"); + } + else + { + Cache.setProperty("FIGURE_FIXEDIDWIDTH", + String.valueOf(fixedIdWidth)); + } } } -- 1.7.10.2