SUGGESTED FIX
An idea is to make AWT error handlers synthetic: install a real handler at the very beginning and call the requested handlers from it instead of real calls to XSetErrorHandler(). This would change the sequence of error handlers the following way (compare to what is described in SWT bug #171432):
AWT thread: XToolkit is initialized and sets its global event handler
saved_error_handler = XSetErrorHandler(XlibWrapper.ToolkitErrorHandler)
AWT thread: invokes XToolkit.WITH_XERROR_HANDLER()
the new handler is stored in XToolkit and all the errors from default
toolkit handler are forwared to it
no call to XSetErrorHandler() is performed
GTK thread: invokes gdk_error_trap_push() and remembers the temporary
AWT toolkit error handler (XlibWrapper.ToolkitErrorHandler)
AWT thread: invokes XToolkit.RESTORE_XERROR_HANDLER()
current error handler is cleared, all the subsequent errors are skipped
(or forwarded to saved_error_handler)
no call to XSetErrorHandler() is performed
GTK thread: invokes gdk_error_trap_pop() and again sets
the X error handler to XlibWrapper.ToolkitErrorHandler
AWT thread: on JVM shutdown, XToolkit restores the saved handler
XSetErrorHandler(saved_error_handler)
|