From 557da4cdc4a6606ea75fd88dd5f41a74b8ba1217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 14 Jun 2022 18:44:24 +0200 Subject: [PATCH] Wayland: Fix duplicate monitor connection events GLFW would report a monitor as connected each time its wl_output received an update, for example if its scale changed. This would also cause the monitor to be added to the monitor array again, causing glfwTerminate to segfault when it attempted to destroy its already destroyed wl_output. (cherry picked from commit c3ad3d49ed8b436582a6fbba1c3e64f97087e362) --- README.md | 4 ++++ src/wl_monitor.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 5437853a..f86a7482 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,10 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Size limits included frame size for fallback decorations - [Wayland] Bugfix: Updating `GLFW_DECORATED` had no effect on server-side decorations + - [Wayland] Bugfix: A monitor would be reported as connected again if its scale + changed + - [Wayland] Bugfix: `glfwTerminate` would segfault if any monitor had changed + scale ## Contact diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 52cab9ad..5c97577e 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -95,6 +95,12 @@ static void outputHandleDone(void* userData, struct wl_output* output) monitor->heightMM = (int) (mode->height * 25.4f / 96.f); } + for (int i = 0; i < _glfw.monitorCount; i++) + { + if (_glfw.monitors[i] == monitor) + return; + } + _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST); }