From: Jim Procter Date: Sun, 30 Oct 2022 23:22:32 +0000 (+0000) Subject: JAL-2349 JAL-3855 bizarre resizing exception when resizing protein alignment for... X-Git-Tag: Release_2_11_3_0~23^2~11 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=6e670b92ab0119650fa78ec4c968f600c077babc JAL-2349 JAL-3855 bizarre resizing exception when resizing protein alignment for a linked CDS protein alignment --- diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index c3b44ce..786696c 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -1284,24 +1284,37 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (image == null || imgWidth != image.getWidth(this) || image.getHeight(this) != getHeight()) { - try - { - image = new BufferedImage(imgWidth, - ap.getAnnotationPanel().getHeight(), - BufferedImage.TYPE_INT_RGB); - } catch (OutOfMemoryError oom) + boolean tried = false; + image = null; + while (image == null && !tried) { try { - System.gc(); - } catch (Exception x) + image = new BufferedImage(imgWidth, + ap.getAnnotationPanel().getHeight(), + BufferedImage.TYPE_INT_RGB); + tried = true; + } catch (IllegalArgumentException exc) { + System.err.println( + "Serious issue with viewport geometry imgWidth requested was " + + imgWidth); + return; + } catch (OutOfMemoryError oom) + { + try + { + System.gc(); + } catch (Exception x) + { + } + ; + new OOMWarning( + "Couldn't allocate memory to redraw screen. Please restart Jalview", + oom); + return; } - ; - new OOMWarning( - "Couldn't allocate memory to redraw screen. Please restart Jalview", - oom); - return; + } gg = (Graphics2D) image.getGraphics();