From 5eee4251b781e90ac66c33a2a1bcb7f2f6cf736a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 18 Apr 2013 23:23:09 +0200 Subject: GLJPanel: Avoid NPE of 'backend' in getChosenGLCapabilities() and DisposeGLEventListenerAction.run() ; Make 'backend' volatile due to possible multi-threading access. --- src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/jogl/classes/javax/media/opengl') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 2a68b89d3..1da7001fd 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -163,7 +163,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private int viewportY; // The backend in use - private Backend backend; + private volatile Backend backend; // Used by all backends either directly or indirectly to hook up callbacks private Updater updater = new Updater(); @@ -633,7 +633,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public GLCapabilitiesImmutable getChosenGLCapabilities() { - return backend.getChosenGLCapabilities(); + if(null != backend) { + return backend.getChosenGLCapabilities(); + } + return null; } @Override @@ -830,7 +833,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void run() { - listener = helper.disposeGLEventListener(GLJPanel.this, backend.getDrawable(), backend.getContext(), listener, remove); + if( null != backend ) { + listener = helper.disposeGLEventListener(GLJPanel.this, backend.getDrawable(), backend.getContext(), listener, remove); + } } }; -- cgit v1.2.3