From: James Procter Date: Tue, 6 Jun 2023 16:59:35 +0000 (+0100) Subject: JAL-4160 JAL-4195 wait around until alignFrame calculators are finished before trying... X-Git-Tag: Release_2_11_4_0~213^2~22^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=340ebd50b63087b4f8b2c4a26d94112dc51ada9c;p=jalview.git JAL-4160 JAL-4195 wait around until alignFrame calculators are finished before trying to output an image --- diff --git a/src/jalview/bin/Commands.java b/src/jalview/bin/Commands.java index 3d47505..fc8a51a 100644 --- a/src/jalview/bin/Commands.java +++ b/src/jalview/bin/Commands.java @@ -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); diff --git a/src/jalview/workers/AlignCalcManager.java b/src/jalview/workers/AlignCalcManager.java index 08ef3a2..d81db8c 100644 --- a/src/jalview/workers/AlignCalcManager.java +++ b/src/jalview/workers/AlignCalcManager.java @@ -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 workers : updating.values()) + { + working |= workers.size() > 0; + } + } + return working; } @Override