From cb25f36c03700f3d42099d89a4f676c5d6cc63d7 Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 12 Nov 2007 16:28:57 +0000 Subject: [PATCH] bugfix for occasional race condition causing exception in swing method for retrieving all desktop windows --- src/jalview/gui/Jalview2XML.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index aab41ca..805fd68 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -2070,8 +2070,21 @@ public class Jalview2XML int height = ids[p].getStructureState(s).getHeight(); java.awt.Component comp = null; - - JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + + JInternalFrame[] frames = null; + do { + try { + frames = Desktop.desktop.getAllFrames(); + } + catch (ArrayIndexOutOfBoundsException e) + { + // occasional No such child exceptions are thrown here... + frames = null; + try { + Thread.sleep(10); + } catch (Exception f) {}; + } + } while (frames==null); for (int f = 0; f < frames.length; f++) { if (frames[f] instanceof AppJmol) -- 1.7.10.2