From b8719513e0b9b89a731d462cc6d1930e2dc5bb48 Mon Sep 17 00:00:00 2001 From: James Procter Date: Thu, 6 Jul 2023 17:35:17 +0100 Subject: [PATCH] JAL-4217 catch case when the structure viewer doesn't get added to the desktop window (possible knock on for flatlaf JAL-3416) --- src/jalview/gui/Desktop.java | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 36d6434..12ff20b 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1078,7 +1078,36 @@ public class Desktop extends jalview.jbgui.GDesktop setKeyBindings(frame); - desktop.add(frame); + // Since the latest FlatLaf patch, we occasionally have problems showing structureViewer frames... + int tries=3; + boolean shown=false; + Exception last=null; + do + { + try + { + desktop.add(frame); + shown=true; + } catch (IllegalArgumentException iaex) + { + last=iaex; + tries--; + jalview.bin.Console.info( + "Squashed IllegalArgument Exception (" + tries + " left) for "+frame.getTitle(), + iaex); + try + { + Thread.sleep(5); + } catch (InterruptedException iex) + { + } + ; + } + } while (!shown && tries > 0); + if (!shown) + { + jalview.bin.Console.error("Serious Problem whilst showing window "+frame.getTitle(),last); + } windowMenu.add(menuItem); -- 1.7.10.2