mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
X11: Fix previous error handler not being restored
GLFW did not restore the previous Xlib error handler when removing its
own, instead resetting to the default handler.
This commit saves and restores the previous error handler.
None of this is thread-safe or could ever be.
Fixes #2108
(cherry picked from commit 26920a1a38
)
This commit is contained in:
parent
416f7828ff
commit
631da8cc2f
@ -136,6 +136,7 @@ information on what to include when reporting a bug.
|
|||||||
- [Cocoa] Bugfix: The EGL and OSMesa libraries were not unloaded on termination
|
- [Cocoa] Bugfix: The EGL and OSMesa libraries were not unloaded on termination
|
||||||
- [X11] Bugfix: The OSMesa libray was not unloaded on termination
|
- [X11] Bugfix: The OSMesa libray was not unloaded on termination
|
||||||
- [X11] Bugfix: A malformed response during selection transfer could cause a segfault
|
- [X11] Bugfix: A malformed response during selection transfer could cause a segfault
|
||||||
|
- [X11] Bugfix: Some calls would reset Xlib to the default error handler (#2108)
|
||||||
- [Wayland] Added support for file path drop events (#2040)
|
- [Wayland] Added support for file path drop events (#2040)
|
||||||
- [Wayland] Bugfix: `glfwSetClipboardString` would fail if set to result of
|
- [Wayland] Bugfix: `glfwSetClipboardString` would fail if set to result of
|
||||||
`glfwGetClipboardString`
|
`glfwGetClipboardString`
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
// Translate the X11 KeySyms for a key to a GLFW key code
|
// Translate the X11 KeySyms for a key to a GLFW key code
|
||||||
@ -1022,8 +1023,9 @@ static int errorHandler(Display *display, XErrorEvent* event)
|
|||||||
//
|
//
|
||||||
void _glfwGrabErrorHandlerX11(void)
|
void _glfwGrabErrorHandlerX11(void)
|
||||||
{
|
{
|
||||||
|
assert(_glfw.x11.errorHandler == NULL);
|
||||||
_glfw.x11.errorCode = Success;
|
_glfw.x11.errorCode = Success;
|
||||||
XSetErrorHandler(errorHandler);
|
_glfw.x11.errorHandler = XSetErrorHandler(errorHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clears the X error handler callback
|
// Clears the X error handler callback
|
||||||
@ -1032,7 +1034,8 @@ void _glfwReleaseErrorHandlerX11(void)
|
|||||||
{
|
{
|
||||||
// Synchronize to make sure all commands are processed
|
// Synchronize to make sure all commands are processed
|
||||||
XSync(_glfw.x11.display, False);
|
XSync(_glfw.x11.display, False);
|
||||||
XSetErrorHandler(NULL);
|
XSetErrorHandler(_glfw.x11.errorHandler);
|
||||||
|
_glfw.x11.errorHandler = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reports the specified error, appending information about the last X error
|
// Reports the specified error, appending information about the last X error
|
||||||
|
@ -222,6 +222,8 @@ typedef struct _GLFWlibraryX11
|
|||||||
XContext context;
|
XContext context;
|
||||||
// XIM input method
|
// XIM input method
|
||||||
XIM im;
|
XIM im;
|
||||||
|
// The previous X error handler, to be restored later
|
||||||
|
XErrorHandler errorHandler;
|
||||||
// Most recent error code received by X error handler
|
// Most recent error code received by X error handler
|
||||||
int errorCode;
|
int errorCode;
|
||||||
// Primary selection string (while the primary selection is owned)
|
// Primary selection string (while the primary selection is owned)
|
||||||
|
Loading…
Reference in New Issue
Block a user