From: Jim Procter Date: Mon, 8 Nov 2021 18:15:33 +0000 (+0000) Subject: JAL-3921 wait around until session file has been written X-Git-Tag: Release_2_11_2_0~22^2~3 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=b1c6252371bbf235ea9135b58a33defe799874f2;p=jalview.git JAL-3921 wait around until session file has been written --- diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 4f746cb..1c0f43e 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -1210,8 +1210,23 @@ public abstract class StructureViewerBase extends GStructureViewer */ public File saveSession() { - // TODO: a wait loop to ensure the file is written fully before returning? - return getBinding() == null ? null : getBinding().saveSession(); + if (getBinding() == null) { return null;} + File session = getBinding().saveSession(); + long l = session.length(); + int wait=50; + do { + try { + Thread.sleep(5); + } catch (InterruptedException e) { + } + long nextl = session.length(); + if (nextl!=l) + { + wait = 50; + l=nextl; + } + } while (--wait>0); + return session; } /**