JAL-612 - catch hidden OOM related to filling in cut and paste text boxes
authorjprocter <Jim Procter>
Wed, 18 Aug 2010 16:50:34 +0000 (16:50 +0000)
committerjprocter <Jim Procter>
Wed, 18 Aug 2010 16:50:34 +0000 (16:50 +0000)
src/MCview/PDBViewer.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AnnotationExporter.java
src/jalview/gui/TreePanel.java

index 50a501d..35e2308 100755 (executable)
@@ -564,8 +564,14 @@ public class PDBViewer extends JInternalFrame implements Runnable
   public void mapping_actionPerformed(ActionEvent e)
   {
     jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
-    Desktop.addInternalFrame(cap, "PDB - Sequence Mapping", 550, 600);
-    cap.setText(pdbcanvas.mappingDetails.toString());
+    try {
+      cap.setText(pdbcanvas.mappingDetails.toString());
+      Desktop.addInternalFrame(cap, "PDB - Sequence Mapping", 550, 600);
+    } catch (OutOfMemoryError oom)
+    {
+      new OOMWarning("Opening sequence to structure mapping report",oom);
+      cap.dispose();
+    }
   }
 
   public void allchains_itemStateChanged(ItemEvent e)
index 3ac30ae..b0d30a2 100755 (executable)
@@ -1005,11 +1005,18 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     CutAndPasteTransfer cap = new CutAndPasteTransfer();
     cap.setForInput(null);
+
+    try {
+      cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
+            viewport.alignment, omitHidden, viewport.colSel));
     Desktop.addInternalFrame(cap, "Alignment output - "
             + e.getActionCommand(), 600, 500);
+    } catch (OutOfMemoryError oom)
+    {
+      new OOMWarning("Outputting alignment as "+e.getActionCommand(),oom);
+      cap.dispose();
+    }
 
-    cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
-            viewport.alignment, omitHidden, viewport.colSel));
   }
 
   /**
index 118aab8..857eabc 100755 (executable)
@@ -88,8 +88,8 @@ public class AnnotationExporter extends JPanel
 \r
   public void toFile_actionPerformed(ActionEvent e)\r
   {\r
-    JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache\r
-            .getProperty("LAST_DIRECTORY"));\r
+    JalviewFileChooser chooser = new JalviewFileChooser(\r
+            jalview.bin.Cache.getProperty("LAST_DIRECTORY"));\r
 \r
     chooser.setFileView(new JalviewFileView());\r
     chooser.setDialogTitle(features ? "Save Features to File"\r
@@ -177,10 +177,18 @@ public class AnnotationExporter extends JPanel
     }\r
 \r
     CutAndPasteTransfer cap = new CutAndPasteTransfer();\r
-    cap.setText(text);\r
-    Desktop.addInternalFrame(cap, (features ? "Features for - "\r
-            : "Annotations for - ")\r
-            + ap.alignFrame.getTitle(), 600, 500);\r
+    try\r
+    {\r
+      cap.setText(text);\r
+      Desktop.addInternalFrame(cap, (features ? "Features for - "\r
+              : "Annotations for - ") + ap.alignFrame.getTitle(), 600, 500);\r
+    } catch (OutOfMemoryError oom)\r
+    {\r
+      new OOMWarning("generating "\r
+              + (features ? "Features for - " : "Annotations for - ")\r
+              + ap.alignFrame.getTitle(), oom);\r
+      cap.dispose();\r
+    }\r
 \r
     close_actionPerformed(null);\r
   }\r
index 45fc0df..cc63ee4 100755 (executable)
@@ -364,12 +364,19 @@ public class TreePanel extends GTreePanel
       buffer.append("PID");
     }
 
-    Desktop.addInternalFrame(cap, buffer.toString(), 500, 100);
 
     jalview.io.NewickFile fout = new jalview.io.NewickFile(tree
             .getTopNode());
-    cap.setText(fout.print(tree.isHasBootstrap(), tree.isHasDistances(),
+    try {
+      cap.setText(fout.print(tree.isHasBootstrap(), tree.isHasDistances(),
             tree.isHasRootDistance()));
+      Desktop.addInternalFrame(cap, buffer.toString(), 500, 100);
+    } catch (OutOfMemoryError oom)
+    {
+      new OOMWarning("generating newick tree file",oom);
+      cap.dispose();
+    }
+
   }
 
   /**