JAL-3626 use Viewer.scriptWait() to send Jmol commands (Bob Hanson)
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 20 May 2020 07:51:38 +0000 (08:51 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 20 May 2020 07:51:38 +0000 (08:51 +0100)
src/jalview/ext/jmol/JalviewJmolBinding.java
src/jalview/gui/AppJmol.java

index 54eb599..038ca48 100644 (file)
@@ -115,7 +115,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   private String jmolScript(String script)
   {
     Cache.log.debug(">>Jmol>> " + script);
-    String s = jmolViewer.evalStringQuiet(script);
+    String s = jmolViewer.scriptWait(script);
     Cache.log.debug("<<Jmol<< " + s);
 
     return s;
@@ -210,7 +210,10 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
           mset.add(filePath);
         }
       }
-      modelFileNames = mset.toArray(new String[mset.size()]);
+      if (!mset.isEmpty())
+      {
+        modelFileNames = mset.toArray(new String[mset.size()]);
+      }
     }
 
     return modelFileNames;
index 4058cda..ffc8053 100644 (file)
@@ -344,8 +344,10 @@ public class AppJmol extends StructureViewerBase
       try
       {
         Cache.log.debug("Waiting around for jmb notify.");
-        Thread.sleep(waitFor);
         waitTotal += waitFor;
+
+        // Thread.sleep() throws an exception in JS
+        Thread.sleep(waitFor);
       } catch (Exception e)
       {
       }