diff options
author | Sven Gothel <[email protected]> | 2013-04-23 08:12:25 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-04-23 08:12:25 +0200 |
commit | 9711076d8d34ae4235697bee782eaf36f487e0ca (patch) | |
tree | 7c9aaf14f3889a6db7e921da4ff31279fb3876c3 /src/jogl/classes/javax/media | |
parent | 5673f6525604d370e236fbc62f838af781096206 (diff) |
Complete intend of commit cdbf3f42ea530f91639536e03b2c203715c3c300 - Test for null against a temp variable to narrow races
Diffstat (limited to 'src/jogl/classes/javax/media')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index a8c7f7eb2..383c40dc3 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -510,10 +510,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public GLContext createContext(GLContext shareWith) { - Backend b = backend; - if (b == null) + final Backend b = backend; + if ( null == b ) { return null; - + } return b.createContext(shareWith); } @@ -528,30 +528,33 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx) { - if (backend == null) { - return null; - } - final GLContext oldCtx = backend.getContext(); - GLDrawableHelper.switchContext(backend.getDrawable(), oldCtx, destroyPrevCtx, newCtx, additionalCtxCreationFlags); - backend.setContext(newCtx); - return oldCtx; + final Backend b = backend; + if ( null == b ) { + return null; + } + final GLContext oldCtx = b.getContext(); + GLDrawableHelper.switchContext(b.getDrawable(), oldCtx, destroyPrevCtx, newCtx, additionalCtxCreationFlags); + b.setContext(newCtx); + return oldCtx; } @Override public final GLDrawable getDelegatedDrawable() { - if (backend == null) { - return null; + final Backend b = backend; + if ( null == b ) { + return null; } - return backend.getDrawable(); + return b.getDrawable(); } @Override public GLContext getContext() { - if (backend == null) { - return null; + final Backend b = backend; + if ( null == b ) { + return null; } - return backend.getContext(); + return b.getContext(); } @Override @@ -629,18 +632,19 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public boolean isGLOriented() { - if(null != backend) { - return backend.getDrawable().isGLOriented(); + final Backend b = backend; + if ( null == b ) { + return true; } - return true; + return b.getDrawable().isGLOriented(); } @Override public GLCapabilitiesImmutable getChosenGLCapabilities() { - Backend b = backend; - if (b == null) + final Backend b = backend; + if ( null == b ) { return null; - + } return b.getChosenGLCapabilities(); } @@ -651,18 +655,20 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public NativeSurface getNativeSurface() { - if(null != backend) { - return backend.getDrawable().getNativeSurface(); + final Backend b = backend; + if ( null == b ) { + return null; } - return null; + return b.getDrawable().getNativeSurface(); } @Override public long getHandle() { - if(null != backend) { - return backend.getDrawable().getNativeSurface().getSurfaceHandle(); + final Backend b = backend; + if ( null == b ) { + return 0; } - return 0; + return b.getDrawable().getNativeSurface().getSurfaceHandle(); } @Override @@ -838,8 +844,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void run() { - Backend b = backend; - if (null != b) { + final Backend b = backend; + if ( null != b ) { listener = helper.disposeGLEventListener(GLJPanel.this, b.getDrawable(), b.getContext(), listener, remove); } } |