Переглянути джерело

Wayland: Fix segfault on termination

A segfault could occur during termination if libdecor was found but no
windows were created between initialization and termination.  The wait
for libdecor to finish its initialization was only performed before
window creation, not at termination.

Regression introduced by 9fdc425931888ea70bc095e53cc006fca8ccb703.
Camilla Löwy 1 рік тому
батько
коміт
4e8c4901e9
1 змінених файлів з 7 додано та 2 видалено
  1. 7 2
      src/wl_init.c

+ 7 - 2
src/wl_init.c

@@ -846,10 +846,15 @@ void _glfwTerminateWayland(void)
     _glfwTerminateEGL();
     _glfwTerminateEGL();
     _glfwTerminateOSMesa();
     _glfwTerminateOSMesa();
 
 
-    if (_glfw.wl.libdecor.callback)
-        wl_callback_destroy(_glfw.wl.libdecor.callback);
     if (_glfw.wl.libdecor.context)
     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);
         libdecor_unref(_glfw.wl.libdecor.context);
+    }
 
 
     if (_glfw.wl.libdecor.handle)
     if (_glfw.wl.libdecor.handle)
     {
     {