Clean up Wayland resources on wxGLCanvas destructor

If the wxGLCanvas is destroyed immediately (without hiding it first),
the GTKs widget's `unmap` signal which usually destroys the Wayland
resources is not emitted. Thus, we need to ensure they are destroyed
on the destructor instead.

This fixes an use-after-free issue, sometimes causing a crash, because
one of the leaked resources is the canvas's Wayland frame callback.

See #24013, #24016.

(cherry picked from commit 22ae7a58b5412463194b446426296b588368bff8)
This commit is contained in:
Joan Bruguera Micó 2023-10-29 22:41:53 +00:00 committed by Vadim Zeitlin
parent 45ac25826b
commit 3d235b8da6

View File

@ -630,6 +630,7 @@ wxGLCanvasEGL::~wxGLCanvasEGL()
if ( m_surface )
eglDestroySurface(m_display, m_surface);
#ifdef GDK_WINDOWING_WAYLAND
DestroyWaylandSubsurface();
g_clear_pointer(&m_wlEGLWindow, wl_egl_window_destroy);
g_clear_pointer(&m_wlSurface, wl_surface_destroy);