diff --git a/src/egl_context.c b/src/egl_context.c index 0ef7f7295..921d5c6eb 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -555,7 +555,8 @@ void _glfwTerminateEGL(void) _glfw.egl.display = EGL_NO_DISPLAY; } - if (_glfw.egl.handle) + // Free modules only after all wayland termination functions are called + if (_glfw.egl.handle && _glfw.platform.platformID != GLFW_PLATFORM_WAYLAND) { _glfwPlatformFreeModule(_glfw.egl.handle); _glfw.egl.handle = NULL; diff --git a/src/wl_init.c b/src/wl_init.c index c7f9bf9e4..33a61163f 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -982,6 +982,12 @@ void _glfwTerminateWayland(void) close(_glfw.wl.cursorTimerfd); // Free modules only after all wayland termination functions are called + if (_glfw.egl.handle) + { + _glfwPlatformFreeModule(_glfw.egl.handle); + _glfw.egl.handle = NULL; + } + if (_glfw.wl.libdecor.handle) { _glfwPlatformFreeModule(_glfw.wl.libdecor.handle);