JAL-2665 OOM checks just in case bug/JAL-2665-2.10.3
authorkiramt <k.mourao@dundee.ac.uk>
Tue, 29 Aug 2017 10:56:20 +0000 (11:56 +0100)
committerkiramt <k.mourao@dundee.ac.uk>
Tue, 29 Aug 2017 10:56:20 +0000 (11:56 +0100)
src/jalview/gui/SeqCanvas.java

index f34ab2c..ba53ca8 100755 (executable)
@@ -453,30 +453,34 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
           int canvasHeight, int startRes)
   {
     SequenceGroup group = av.getSelectionGroup();
-    BufferedImage selectImage = null;
 
-    try
-    {
-      selectImage = new BufferedImage(canvasWidth, canvasHeight,
-              BufferedImage.TYPE_INT_ARGB); // ARGB so alpha compositing works
-    } catch (OutOfMemoryError er)
-    {
-      System.gc();
-      System.err.println("Print image OutOfMemory Error.\n" + er);
-      new OOMWarning("Creating wrapped alignment image for printing", er);
-
-      return;
-    }
+    drawWrappedPanel(g, canvasWidth, canvasHeight, startRes);
 
     if (group != null)
     {
-      Graphics2D g2 = selectImage.createGraphics();
-      setupSelectionGroup(g2, selectImage);
-      drawWrappedSelection(g2, group, canvasWidth, canvasHeight, startRes);
-      drawWrappedPanel(g, canvasWidth, canvasHeight, startRes);
-      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
-      g.drawImage(selectImage, 0, 0, this);
-      g2.dispose();
+      BufferedImage selectImage = null;
+      try
+      {
+        selectImage = new BufferedImage(canvasWidth, canvasHeight,
+                BufferedImage.TYPE_INT_ARGB); // ARGB so alpha compositing works
+      } catch (OutOfMemoryError er)
+      {
+        System.gc();
+        System.err.println("Print image OutOfMemory Error.\n" + er);
+        new OOMWarning("Creating wrapped alignment image for printing", er);
+      }
+      if (selectImage != null)
+      {
+        Graphics2D g2 = selectImage.createGraphics();
+        setupSelectionGroup(g2, selectImage);
+        drawWrappedSelection(g2, group, canvasWidth, canvasHeight,
+                startRes);
+
+        g2.setComposite(
+                AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
+        g.drawImage(selectImage, 0, 0, this);
+        g2.dispose();
+      }
     }
   }