JAL-612 - catch hidden OOM related to filling in cut and paste text boxes
[jalview.git] / src / jalview / gui / TreePanel.java
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();
+    }
+
   }
 
   /**