diff options
author | Sven Gothel <[email protected]> | 2013-07-04 20:19:35 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-07-04 20:19:35 +0200 |
commit | 99479bf3197cde8e89c5b499d135417863d521c7 (patch) | |
tree | fd4ae1f0532c750a3ac02af2edb74ed83ebf0743 /src/jogl/classes/jogamp | |
parent | 1d9e043f6e0acba2dde9d4afd57bc75141ed050f (diff) |
NEWT: Using WeakReferences for global cache of Display, Screen and Window instances; Removing ref. at API destroy() is wrong ; Allow GC to clear ..
- Removing ref. at API destroy() is wrong
- Since all instances can be recreated, removing ref at destroy() is simply wrong.
- Keep weak references until GC collects, i.e. user does not claim them anymore.
- Safe for Display, since it holds it's EDT thread.
- Window/Screen .. if user abandons reference .. nothing we can do here.
- Allow GC to clear ..
No need to hold ref loonger than user.
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index 910158d1f..4bd7bc994 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -117,8 +117,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { createdContexts.add(new WeakReference<MacOSXCGLContext>(osxCtx)); } else { for(int i=0; i<createdContexts.size(); ) { - final WeakReference<MacOSXCGLContext> ref = createdContexts.get(i); - final MacOSXCGLContext _ctx = ref.get(); + final MacOSXCGLContext _ctx = createdContexts.get(i).get(); if( _ctx == null || _ctx == ctx) { createdContexts.remove(i); } else { @@ -134,8 +133,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { if(doubleBuffered) { synchronized (createdContexts) { for(int i=0; i<createdContexts.size(); ) { - final WeakReference<MacOSXCGLContext> ref = createdContexts.get(i); - final MacOSXCGLContext ctx = ref.get(); + final MacOSXCGLContext ctx = createdContexts.get(i).get(); if (ctx != null) { ctx.swapBuffers(); i++; |