diff options
author | Campbell Barton <campbell@blender.org> | 2022-06-22 06:08:55 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-06-22 06:11:32 +0300 |
commit | 8fab580949374e6208cee2e9ba2caf249bc0c1fd (patch) | |
tree | 98a6c5aa293dccc4761ff0c56673081df583cd82 /intern/ghost/intern/GHOST_WindowWayland.cpp | |
parent | c08fda3a6b1d05b5af76997436260fe881ff74c2 (diff) |
Fix T99078: Crash closing the file selector in Wayland
Ensure wayland handlers run that clear the window immediately after
the window has been removed so dangling pointers to the window
aren't left set.
Diffstat (limited to 'intern/ghost/intern/GHOST_WindowWayland.cpp')
-rw-r--r-- | intern/ghost/intern/GHOST_WindowWayland.cpp | 14 |
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; } |