From d64f1df4fdb6c90c7ed36624174eac8b1dd52511 Mon Sep 17 00:00:00 2001 From: jprocter Date: Tue, 25 Sep 2012 11:20:17 +0100 Subject: [PATCH] JAL-1173 - trap redraw buffer OOM errors. needs a test case - since the dialog doesn't get raised reliably. --- src/jalview/gui/AnnotationPanel.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 411c244..23d8341 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -754,8 +754,17 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (image == null || imgWidth != image.getWidth() || image.getHeight(this) != getHeight()) { + try { image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(), BufferedImage.TYPE_INT_RGB); + } catch (OutOfMemoryError oom) + { + try { + System.gc(); + } catch (Exception x){}; + new OOMWarning("Couldn't allocate memory to redraw screen. Please restart Jalview", oom); + return; + } gg = (Graphics2D) image.getGraphics(); if (av.antiAlias) -- 1.7.10.2