JAL-4160 JAL-4195 wait around until alignFrame calculators are finished before trying...
authorJames Procter <j.procter@dundee.ac.uk>
Tue, 6 Jun 2023 16:59:35 +0000 (17:59 +0100)
committerJames Procter <j.procter@dundee.ac.uk>
Tue, 6 Jun 2023 17:00:22 +0000 (18:00 +0100)
src/jalview/bin/Commands.java
src/jalview/workers/AlignCalcManager.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);
index 08ef3a2..d81db8c 100644 (file)
@@ -200,11 +200,20 @@ public class AlignCalcManager implements AlignCalcManagerI
   @Override
   public boolean isWorking()
   {
+    boolean working=false;
     synchronized (inProgress)
     {
       // System.err.println("isWorking "+hashCode());
-      return inProgress.size() > 0;
+      working |= inProgress.size() > 0;
     }
+    synchronized (updating)
+    {
+      for (List<AlignCalcWorkerI> workers : updating.values())
+      {
+        working |= workers.size() > 0;
+      }
+    }
+    return working;
   }
 
   @Override