From 2083ba25be5ce9b55cc2f5a420f17c3bb5ff1750 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 9 Sep 2011 15:34:01 +0200 Subject: X11Util: Catch X11 Error on XCloseDisplay --- .../classes/jogamp/nativewindow/x11/X11Util.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/nativewindow/classes') diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index ec4602836..5c1839250 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -408,6 +408,10 @@ public class X11Util { if(!openDisplayList.remove(namedDpy)) { throw new RuntimeException("Internal: "+namedDpy); } if(!namedDpy.isUncloseable()) { + if(DEBUG) { + System.err.println("X11Util.Display: XCloseDisplay "+namedDpy+". Thread "+Thread.currentThread().getName()); + Thread.dumpStack(); + } XCloseDisplay(namedDpy.getHandle()); } else { // for reuse @@ -415,8 +419,7 @@ public class X11Util { } if(DEBUG) { - Exception e = new Exception("X11Util.Display: Closing new "+namedDpy+". Thread "+Thread.currentThread().getName()); - e.printStackTrace(); + System.err.println("X11Util.Display: Closed (real: "+(!namedDpy.isUncloseable())+") "+namedDpy+". Thread "+Thread.currentThread().getName()); } } } @@ -468,7 +471,17 @@ public class X11Util { Throwable t = new Throwable(Thread.currentThread()+" - X11Util.XCloseDisplay() 0x"+Long.toHexString(display)); t.printStackTrace(); } - return X11Lib.XCloseDisplay(display); + int res = -1; + X11Util.setX11ErrorHandler(true, DEBUG ? false : true); + try { + res = X11Lib.XCloseDisplay(display); + } catch (Exception ex) { + System.err.println("X11Util: Catched Exception:"); + ex.printStackTrace(); + } finally { + X11Util.setX11ErrorHandler(false, false); + } + return res; } finally { NativeWindowFactory.getDefaultToolkitLock().unlock(); } -- cgit v1.2.3