update author list in license for (JAL-826)
[jalview.git] / src / jalview / gui / OOMWarning.java
index a2d1ede..2195fb2 100644 (file)
@@ -1,20 +1,19 @@
 /*\r
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)\r
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)\r
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle\r
  * \r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
+ * This file is part of Jalview.\r
  * \r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
+ * Jalview is free software: you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License \r
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\r
  * \r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+ * Jalview is distributed in the hope that it will be useful, but \r
+ * WITHOUT ANY WARRANTY; without even the implied warranty \r
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
+ * PURPOSE.  See the GNU General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.\r
  */\r
 package jalview.gui;\r
 \r
@@ -26,36 +25,44 @@ public class OOMWarning implements Runnable
 \r
   String instructions = "";\r
 \r
+  public static boolean oomInprogress = false;\r
+\r
   Component desktop = null;\r
 \r
   /**\r
    * Raise an out of memory error.\r
    * \r
-   * @param action -\r
-   *                what was going on when OutOfMemory exception occured.\r
-   * @param instance -\r
-   *                Window where the dialog will appear\r
-   * @param oomex -\r
-   *                the actual exception - to be written to stderr or debugger.\r
+   * @param action\r
+   *          - what was going on when OutOfMemory exception occured.\r
+   * @param instance\r
+   *          - Window where the dialog will appear\r
+   * @param oomex\r
+   *          - the actual exception - to be written to stderr or debugger.\r
    */\r
-  OOMWarning(String action, OutOfMemoryError oomex, Component instance)\r
+  OOMWarning(final String action, final OutOfMemoryError oomex,\r
+          final Component instance)\r
   {\r
-    this.action = action;\r
-    desktop = instance;\r
-    if (oomex != null)\r
+    if (!oomInprogress)\r
     {\r
-      if (jalview.bin.Cache.log != null)\r
-      {\r
-        jalview.bin.Cache.log.error("Out of Memory when " + action, oomex);\r
-      }\r
-      else\r
+      oomInprogress = true;\r
+      this.action = action;\r
+      desktop = instance;\r
+      if (oomex != null)\r
       {\r
-        System.err.println("Out of Memory when " + action);\r
-        oomex.printStackTrace();\r
+        if (jalview.bin.Cache.log != null)\r
+        {\r
+          jalview.bin.Cache.log\r
+                  .error("Out of Memory when " + action, oomex);\r
+        }\r
+        else\r
+        {\r
+          System.err.println("Out of Memory when " + action);\r
+          oomex.printStackTrace();\r
+        }\r
       }\r
+      javax.swing.SwingUtilities.invokeLater(this);\r
+      System.gc();\r
     }\r
-    javax.swing.SwingUtilities.invokeLater(this);\r
-    System.gc();\r
   }\r
 \r
   public OOMWarning(String string, OutOfMemoryError oomerror)\r
@@ -74,6 +81,8 @@ public class OOMWarning implements Runnable
                             + "\nSee help files for increasing Java Virtual Machine memory.",\r
                     "Out of memory",\r
                     javax.swing.JOptionPane.WARNING_MESSAGE);\r
+    // hope that there's enough memory left that no more appear.\r
+    oomInprogress = false;\r
   }\r
 \r
 }\r