From a8a602a77b811d88cdbbfdb90d8fa6984b9344ae Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 14 Jun 2010 12:47:21 +0000 Subject: [PATCH] stop multiple dialogs appearing one after another (in progress for JAL-414) --- src/jalview/gui/OOMWarning.java | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/jalview/gui/OOMWarning.java b/src/jalview/gui/OOMWarning.java index 3f2b5a8..48db5d9 100644 --- a/src/jalview/gui/OOMWarning.java +++ b/src/jalview/gui/OOMWarning.java @@ -25,6 +25,8 @@ public class OOMWarning implements Runnable String instructions = ""; + public static boolean oomInprogress = false; + Component desktop = null; /** @@ -40,22 +42,27 @@ public class OOMWarning implements Runnable OOMWarning(final String action, final OutOfMemoryError oomex, final Component instance) { - this.action = action; - desktop = instance; - if (oomex != null) + if (!oomInprogress) { - if (jalview.bin.Cache.log != null) - { - jalview.bin.Cache.log.error("Out of Memory when " + action, oomex); - } - else + oomInprogress = true; + this.action = action; + desktop = instance; + if (oomex != null) { - System.err.println("Out of Memory when " + action); - oomex.printStackTrace(); + if (jalview.bin.Cache.log != null) + { + jalview.bin.Cache.log + .error("Out of Memory when " + action, oomex); + } + else + { + System.err.println("Out of Memory when " + action); + oomex.printStackTrace(); + } } + javax.swing.SwingUtilities.invokeLater(this); + System.gc(); } - javax.swing.SwingUtilities.invokeLater(this); - System.gc(); } public OOMWarning(String string, OutOfMemoryError oomerror) @@ -74,6 +81,8 @@ public class OOMWarning implements Runnable + "\nSee help files for increasing Java Virtual Machine memory.", "Out of memory", javax.swing.JOptionPane.WARNING_MESSAGE); + // hope that there's enough memory left that no more appear. + oomInprogress=false; } } -- 1.7.10.2