From 5c83989b8bb8e8f9cbc25f09e6a6fe5847e6b94c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 30 Jun 2012 15:44:55 +0200 Subject: Fix Bug 597: XDisplayString(0) -> SIGSEGV; Handle n/a DISPLAY It works now as follows: Note: Remote connection tested using ssh to localhost or an actual remote machine. Test w/ proper X11 authentication, i.e. DISPLAY and xauth: > cd projects/JOGL/jogl-bugs/597-headless/ > echo $DISPLAY localhost:10.0 > xclock 'works' T1.1 OK> java plop jogamp.opengl.x11.glx.X11GLXDrawableFactory@f581593 T1.2 OK> java -Djava.awt.headless=true plop jogamp.opengl.x11.glx.X11GLXDrawableFactory@6f34a7d8 +++ Test _without_ proper X11 authentication, i.e. DISPLAY and xauth: > xclock No protocol specified No protocol specified Error: Can't open display: :0.0 T2.1 OK> java plop No protocol specified No protocol specified Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable. (Stack trace from: GLProfile.initProfilesForDefaultDevices(..) -> NativeWindowFactory.initSingleton(..) -> JAWTUtil.-> sun.awt.X11.XToolkit. -> sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) T2.2 OK> java -Djava.awt.headless=true plop No protocol specified No protocol specified ... jogamp.opengl.x11.glx.X11GLXDrawableFactory@394a8cd1 --- .../classes/jogamp/nativewindow/x11/X11Util.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/nativewindow/classes/jogamp') diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index c42bcf816..3c197062a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -109,10 +109,14 @@ public class X11Util { isX11LockAvailable = isXInitThreadsOK && !HAS_XLOCKDISPLAY_BUG ; final long dpy = X11Lib.XOpenDisplay(null); - try { - nullDisplayName = X11Lib.XDisplayString(dpy); - } finally { - X11Lib.XCloseDisplay(dpy); + if(0 != dpy) { + try { + nullDisplayName = X11Lib.XDisplayString(dpy); + } finally { + X11Lib.XCloseDisplay(dpy); + } + } else { + nullDisplayName = "nil"; } if(DEBUG) { -- cgit v1.2.3