JAL-741 (poss related JAL-971) - fix NPE raised when attempting to sort alignment...
[jalview.git] / src / jalview / gui / FeatureSettings.java
index d7f05dc..9e0925b 100644 (file)
@@ -1158,13 +1158,13 @@ public class FeatureSettings extends JPanel
   private String[] getDisplayedFeatureGroups()
   {
     String[] gps = null;
+    ArrayList<String> _gps = new ArrayList<String>();
     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);
         }
       }
     }