From e3feb498c35aed7ab43d43967cb2aeafc7f12fb4 Mon Sep 17 00:00:00 2001 From: js6pak Date: Thu, 8 Feb 2024 23:22:57 +0100 Subject: [PATCH] Ignore X errors after destroyWindow --- src/java/org/lwjgl/opengl/LinuxDisplay.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/java/org/lwjgl/opengl/LinuxDisplay.java b/src/java/org/lwjgl/opengl/LinuxDisplay.java index 4de2a1a8e..41630d547 100644 --- a/src/java/org/lwjgl/opengl/LinuxDisplay.java +++ b/src/java/org/lwjgl/opengl/LinuxDisplay.java @@ -162,6 +162,8 @@ final class LinuxDisplay implements DisplayImplementation { private LinuxMouse mouse; private String wm_class; + + private static boolean destroying; private final FocusListener focus_listener = new FocusListener() { public void focusGained(FocusEvent e) { @@ -334,7 +336,14 @@ private static int globalErrorHandler(long display, long event_ptr, long error_d if (display == getDisplay()) { String error_msg = getErrorText(display, error_code); - throw new LWJGLException("X Error - disp: 0x" + Long.toHexString(error_display) + " serial: " + serial + " error: " + error_msg + " request_code: " + request_code + " minor_code: " + minor_code); + LWJGLException exception = new LWJGLException("X Error - disp: 0x" + Long.toHexString(error_display) + " serial: " + serial + " error: " + error_msg + " request_code: " + request_code + " minor_code: " + minor_code); + + if (destroying) { + exception.printStackTrace(); + return 0; + } + + throw exception; } else if (saved_error_handler != 0) return callErrorHandler(saved_error_handler, display, event_ptr); return 0; @@ -595,6 +604,8 @@ private void updateInputGrab() { public void destroyWindow() { lockAWT(); try { + destroying = true; + if (parent != null) { parent.removeFocusListener(focus_listener); }