diff --git a/src/wl_init.c b/src/wl_init.c index 0ec65900..fd6b7e9c 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -846,10 +846,15 @@ void _glfwTerminateWayland(void) _glfwTerminateEGL(); _glfwTerminateOSMesa(); - if (_glfw.wl.libdecor.callback) - wl_callback_destroy(_glfw.wl.libdecor.callback); if (_glfw.wl.libdecor.context) + { + // Allow libdecor to finish receiving all its requested globals + // and ensure the associated sync callback object is destroyed + while (!_glfw.wl.libdecor.ready) + _glfwWaitEventsWayland(); + libdecor_unref(_glfw.wl.libdecor.context); + } if (_glfw.wl.libdecor.handle) {