From 36d34983bb94678c96143e6a7a8538594c588b7d Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 13 Dec 2023 10:17:22 +0100 Subject: Wayland+GLUT: fix crash in glut_test application - cont'd --- src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx | 3 +++ src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx index ac625fe6f..aec93283b 100644 --- a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx @@ -263,6 +263,9 @@ void Fl_Wayland_Gl_Window_Driver::delete_gl_context(GLContext context) { cached_context = 0; cached_window = 0; } + if (eglGetCurrentContext() == (EGLContext)context) { + eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + } eglDestroyContext(egl_display, (EGLContext)context); eglDestroySurface(egl_display, egl_surface); egl_surface = NULL; diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index 9dda9e460..cd98d23a0 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -1279,8 +1279,7 @@ static const struct wl_callback_listener sync_listener = { static void do_atexit() { - if (Fl_Wayland_Screen_Driver::wl_display && - (!Fl::first_window() || !Fl::first_window()->as_gl_window())) { + if (Fl_Wayland_Screen_Driver::wl_display) { wl_display_roundtrip(Fl_Wayland_Screen_Driver::wl_display); } } -- cgit v1.2.3