summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-09-30 23:18:15 +0200
committerSven Gothel <[email protected]>2014-10-01 00:50:03 +0200
commitf18d1b00e98c982ed90b55218ba28e0e223c8453 (patch)
tree40afa52eb4574ed19e898175bf8c733ed3058227 /src/jogl/classes/javax
parent962f2f597cef74b7d50e5e865d3a5647230166c6 (diff)
Bug 1078: Add Fallback in AWTPrintLifecycle.setupPrint(): Use Onscreen GLAD if Offscreen-GLAD Realization throws an Exception (Stability)
- GLDrawableFactoryImpl: createOffscreenDrawable(..) and createDummyAutoDrawable(..) Temporary catch exception during setRealized(true) of newly created GLDrawable, to unrealize the instance before propagating the exception. This handling removes a memory leak in case the exception of this method is handled and application continues to operate, e.g. as in AWTPrintLifecycle.setupPrint(). The underlying drawable gets unrealized, since it's setRealized(boolean) implementation toggles its realize-state before delegating the realize-operation. Hence this is functional. - AWTPrintLifecycle.setupPrint() Stability Catch exception thrown by factory.createOffscreenAutoDrawable(..)'s setRealize(true) to continue operation w/ onscreen GLAD.
Diffstat (limited to 'src/jogl/classes/javax')
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java22
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java21
2 files changed, 33 insertions, 10 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 563158a72..a648e3bf6 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -82,6 +82,7 @@ import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
+import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLRunnable;
import javax.media.opengl.GLSharedContextSetter;
@@ -893,11 +894,22 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
}
if( reqNewGLAD ) {
final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile());
- printGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
- printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
- printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
- GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD);
- printDrawable = printGLAD.getDelegatedDrawable();
+ GLOffscreenAutoDrawable offGLAD = null;
+ try {
+ offGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
+ printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
+ printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
+ } catch (final GLException gle) {
+ if( DEBUG ) {
+ System.err.println("Caught: "+gle.getMessage());
+ gle.printStackTrace();
+ }
+ }
+ if( null != offGLAD ) {
+ printGLAD = offGLAD;
+ GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD);
+ printDrawable = printGLAD.getDelegatedDrawable();
+ }
}
printAWTTiles.setGLOrientation(printGLAD.isGLOriented(), printGLAD.isGLOriented());
printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0);
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index ff7e1971f..5e78a5df8 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -759,11 +759,22 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
if( reqNewGLAD ) {
final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile());
- printGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
- printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
- printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
- GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD);
- printDrawable = printGLAD.getDelegatedDrawable();
+ GLOffscreenAutoDrawable offGLAD = null;
+ try {
+ offGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
+ printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
+ printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
+ } catch (final GLException gle) {
+ if( DEBUG ) {
+ System.err.println("Caught: "+gle.getMessage());
+ gle.printStackTrace();
+ }
+ }
+ if( null != offGLAD ) {
+ printGLAD = offGLAD;
+ GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD);
+ printDrawable = printGLAD.getDelegatedDrawable();
+ }
}
printAWTTiles.setGLOrientation( !GLJPanel.this.skipGLOrientationVerticalFlip && printGLAD.isGLOriented(), printGLAD.isGLOriented() );
printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0);