diff --git a/src/x11_init.c b/src/x11_init.c index f2c6ae06..3bae1fa3 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -896,30 +896,6 @@ int _glfwPlatformInit(void) void _glfwPlatformTerminate(void) { - if (_glfw.x11.x11xcb.handle) - { - dlclose(_glfw.x11.x11xcb.handle); - _glfw.x11.x11xcb.handle = NULL; - } - - if (_glfw.x11.randr.handle) - { - dlclose(_glfw.x11.randr.handle); - _glfw.x11.randr.handle = NULL; - } - - if (_glfw.x11.xcursor.handle) - { - dlclose(_glfw.x11.xcursor.handle); - _glfw.x11.xcursor.handle = NULL; - } - - if (_glfw.x11.xinerama.handle) - { - dlclose(_glfw.x11.xinerama.handle); - _glfw.x11.xinerama.handle = NULL; - } - if (_glfw.x11.helperWindowHandle) { if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) == @@ -955,6 +931,30 @@ void _glfwPlatformTerminate(void) _glfw.x11.display = NULL; } + if (_glfw.x11.x11xcb.handle) + { + dlclose(_glfw.x11.x11xcb.handle); + _glfw.x11.x11xcb.handle = NULL; + } + + if (_glfw.x11.xcursor.handle) + { + dlclose(_glfw.x11.xcursor.handle); + _glfw.x11.xcursor.handle = NULL; + } + + if (_glfw.x11.randr.handle) + { + dlclose(_glfw.x11.randr.handle); + _glfw.x11.randr.handle = NULL; + } + + if (_glfw.x11.xinerama.handle) + { + dlclose(_glfw.x11.xinerama.handle); + _glfw.x11.xinerama.handle = NULL; + } + // NOTE: This needs to be done after XCloseDisplay, as libGL registers // cleanup callbacks that get called by it _glfwTerminateGLX();