From 99479bf3197cde8e89c5b499d135417863d521c7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Jul 2013 20:19:35 +0200 Subject: 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. --- src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/macosx') 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(osxCtx)); } else { for(int i=0; i 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 ref = createdContexts.get(i); - final MacOSXCGLContext ctx = ref.get(); + final MacOSXCGLContext ctx = createdContexts.get(i).get(); if (ctx != null) { ctx.swapBuffers(); i++; -- cgit v1.2.3