bugfix for occasional race condition causing exception in swing method for retrieving...
authorjprocter <Jim Procter>
Mon, 12 Nov 2007 16:28:57 +0000 (16:28 +0000)
committerjprocter <Jim Procter>
Mon, 12 Nov 2007 16:28:57 +0000 (16:28 +0000)
src/jalview/gui/Jalview2XML.java

index aab41ca..805fd68 100755 (executable)
@@ -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)