JAL-3518 failsafe check for null Jmol filename while loading files
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 12 May 2020 09:37:41 +0000 (10:37 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 12 May 2020 09:37:41 +0000 (10:37 +0100)
src/jalview/ext/jmol/JalviewJmolBinding.java

index 17433c5..061271a 100644 (file)
@@ -188,7 +188,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   @Override
   public synchronized String[] getStructureFiles()
   {
-    List<String> mset = new ArrayList<>();
     if (jmolViewer == null)
     {
       return new String[0];
@@ -198,10 +197,15 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     {
       int modelCount = jmolViewer.ms.mc;
       String filePath = null;
+      List<String> mset = new ArrayList<>();
       for (int i = 0; i < modelCount; ++i)
       {
+        /*
+         * defensive check for null as getModelFileName can return null
+         * even when model count ms.mc is > 0
+         */
         filePath = jmolViewer.ms.getModelFileName(i);
-        if (!mset.contains(filePath))
+        if (filePath != null && !mset.contains(filePath))
         {
           mset.add(filePath);
         }