JAL-4160 JAL-4195 wait around until alignFrame calculators are finished before trying...
[jalview.git] / src / jalview / bin / Commands.java
index 3d47505..fc8a51a 100644 (file)
@@ -100,6 +100,16 @@ public class Commands
         theseArgsWereParsed &= processLinked(id);
         processGroovyScript(id);
         boolean processLinkedOkay = theseArgsWereParsed;
+        
+        // wait around until alignFrame isn't busy
+        AlignFrame af=afMap.get(id);
+        while (af!=null && af.getViewport().isCalcInProgress())
+        {
+          try {
+            Thread.sleep(25);
+          } catch (Exception q) {};
+        }
+        
         theseArgsWereParsed &= processImages(id);
         if (processLinkedOkay)
           theseArgsWereParsed &= processOutput(id);
@@ -107,7 +117,7 @@ public class Commands
         // close ap
         if (avm.getBoolean(Arg.CLOSE))
         {
-          AlignFrame af = afMap.get(id);
+          af = afMap.get(id);
           if (af != null)
           {
             af.closeMenuItem_actionPerformed(true);