From: Jim Procter Date: Sat, 19 Apr 2014 12:56:18 +0000 (+0100) Subject: JAL-741 (poss related JAL-971) - fix NPE raised when attempting to sort alignment... X-Git-Tag: Jalview_2_9~123^2~32 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7c7a5a297e063d3892dd7e629bc317cdde837b81;p=jalview.git JAL-741 (poss related JAL-971) - fix NPE raised when attempting to sort alignment by feature when lots of groups displayed --- diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index d7f05dc..9e0925b 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -1158,13 +1158,13 @@ public class FeatureSettings extends JPanel private String[] getDisplayedFeatureGroups() { String[] gps = null; + ArrayList _gps = new ArrayList(); if (fr != null) { if (fr.featureGroups != null) { Iterator en = fr.featureGroups.keySet().iterator(); - gps = new String[fr.featureColours.size()]; int g = 0; boolean valid = false; while (en.hasNext()) @@ -1174,16 +1174,15 @@ public class FeatureSettings extends JPanel if (on != null && on.booleanValue()) { valid = true; - gps[g++] = gp; + _gps.add(gp); } } - while (g < gps.length) - { - gps[g++] = null; - } if (!valid) { return null; + } else { + gps = new String[_gps.size()]; + _gps.toArray(gps); } } }