From: gmungoc Date: Tue, 12 May 2020 09:37:41 +0000 (+0100) Subject: JAL-3518 failsafe check for null Jmol filename while loading files X-Git-Tag: Release_2_11_2_0~37^2~17^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f236e4e9e66583ca15dce3c3ef0cc43b02bf092e;p=jalview.git JAL-3518 failsafe check for null Jmol filename while loading files --- diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 17433c5..061271a 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -188,7 +188,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel @Override public synchronized String[] getStructureFiles() { - List 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 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); }