From 7e606ef39fa9d73cc7306cc0027989bc7704708d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 29 Oct 2010 03:58:33 +0200 Subject: Proper X11 Display Closing X11Util: Removed TLS semantics, since TLS name -> dpy mapping is erroneous at this point. Added lists for open connections (for optional later shutdown). AbstractGraphicsDevice interface and implementations: Adding 'close()' method allowing native implementations the ability to close the native resource, ie X11GraphicsDevice. This becomes necessary for 'on the fly' created X11 Display connections, ie in X11AWTGLXGraphicsConfigurationFactory, which enables closing. Utilize 'close' call in use cases: GLCanvas, GLJPanel and AWTCanvas. Remove active X11 Display creation in X11JAWTWindow, as a last resort, use the X11SunJDKReflection method. Used for reference only, not active rendering etc, mostly for on the fly AWT parenting in NewtFactoryAWT. However, these 'on the fly' references are erroneous and should be remodelled, ie passice and active X11GraphicsDevice's .. --- .../opengl/impl/x11/glx/X11GLXDrawableFactory.java | 16 +--------------- .../glx/awt/X11AWTGLXGraphicsConfigurationFactory.java | 6 ++++-- 2 files changed, 5 insertions(+), 17 deletions(-) (limited to 'src/jogl/classes/com/jogamp/opengl/impl') diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java index 82f57f33e..3d213c54b 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java @@ -236,23 +236,9 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { System.err.println("!!! Screen : "+sharedScreen); } - // may cause JVM SIGSEGV ? - // X11Util.closePendingDisplayConnections(); - sharedResourcesRunner.releaseAndWait(); - if(X11Util.getOpenDisplayConnectionNumber() > 0) { - System.err.println("X11GLXDrawableFactory.shutdown(): Open (no close attempt) X11 Display Connection"); - X11Util.dumpOpenDisplayConnections(); - } - - if(X11Util.getPendingDisplayConnectionNumber()>0) { - System.err.println("X11GLXDrawableFactory.shutdown(): Pending X11 Display Connection"); - X11Util.dumpPendingDisplayConnections(); - } - - // don't close pending XDisplay, since this might be a different thread as the opener - X11Util.shutdown( false, DEBUG ); + X11Util.shutdown( true, DEBUG ); } protected GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target) { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java index 225dc25a4..4b5b72cc6 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java @@ -83,7 +83,7 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration long displayHandle = X11SunJDKReflection.graphicsDeviceGetDisplay(device); if(0==displayHandle) { - displayHandle = X11Util.createThreadLocalDisplay(null); + displayHandle = X11Util.createDisplay(null); if(DEBUG) { System.err.println("X11AWTGLXGraphicsConfigurationFactory: using a thread local X11 display"); } @@ -91,10 +91,12 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration if(DEBUG) { System.err.println("X11AWTGLXGraphicsConfigurationFactory: using AWT X11 display 0x"+Long.toHexString(displayHandle)); } + String name = X11Util.XDisplayString(displayHandle); + displayHandle = X11Util.createDisplay(name); } ((AWTGraphicsDevice)awtScreen.getDevice()).setSubType(NativeWindowFactory.TYPE_X11, displayHandle); X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle); - + x11Device.setCloseDisplay(true); X11GraphicsScreen x11Screen = new X11GraphicsScreen(x11Device, awtScreen.getIndex()); if(DEBUG) { System.err.println("X11AWTGLXGraphicsConfigurationFactory: made "+x11Screen); -- cgit v1.2.3