Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--intern/ghost/intern/GHOST_WindowWayland.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp
index 941e08ff035..01dd9721f2b 100644
--- a/intern/ghost/intern/GHOST_WindowWayland.cpp
+++ b/intern/ghost/intern/GHOST_WindowWayland.cpp
@@ -586,6 +586,20 @@ GHOST_WindowWayland::~GHOST_WindowWayland()
xdg_surface_destroy(w->xdg_surface);
wl_surface_destroy(w->wl_surface);
+ /* NOTE(@campbellbarton): This is needed so the appropriate handlers event
+ * (#wl_surface_listener.leave in particular) run to prevent access to the freed surfaces.
+ * Without this round-trip, calling #getCursorPosition immediately after closing a window
+ * causes dangling #wl_surface pointers to be accessed
+ * (since the window is used for scaling the cursor position).
+ *
+ * An alternative solution would be to clear all internal pointers that reference this window.
+ * Even though this is reasonable it introduces a 3rd state that needs to be accounted for,
+ * where values are cleared before they have been set to their new values.
+ * Any information requested in this state (such as the cursor position) won't be valid and
+ * could cause difficult to reproduce bugs. So perform a round-trip as closing a window isn't
+ * an action that runs continuously & isn't likely to cause unnecessary overhead. See: T99078. */
+ wl_display_roundtrip(m_system->display());
+
delete w;
}