From 340ebd50b63087b4f8b2c4a26d94112dc51ada9c Mon Sep 17 00:00:00 2001 From: James Procter Date: Tue, 6 Jun 2023 17:59:35 +0100 Subject: [PATCH] JAL-4160 JAL-4195 wait around until alignFrame calculators are finished before trying to output an image --- src/jalview/bin/Commands.java | 12 +++++++++++- src/jalview/workers/AlignCalcManager.java | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) 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 -- 1.7.10.2