From 357d748b18bfbae0ebf7277a3ab1ea2f85cd4cbe Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 13 Jan 2025 09:37:26 +0100 Subject: [PATCH] Fix: Invalid memory access closing window with escape After recent #132539. --- source/blender/windowmanager/intern/wm_event_system.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 9609ef8d562..6638a286ca4 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -3401,6 +3401,8 @@ static eHandlerActionFlag wm_handlers_do_intern(bContext *C, wmEventHandler_KeymapResult km_result; WM_event_get_keymaps_from_handler(wm, win, handler, &km_result); eHandlerActionFlag action_iter = WM_HANDLER_CONTINUE; + /* Compute in advance, as event may be freed on WM_HANDLER_BREAK. */ + const bool event_is_timer = ISTIMER(event->type); for (int km_index = 0; km_index < km_result.keymaps_len; km_index++) { wmKeyMap *keymap = km_result.keymaps[km_index]; action_iter |= wm_handlers_do_keymap_with_keymap_handler( @@ -3413,7 +3415,7 @@ static eHandlerActionFlag wm_handlers_do_intern(bContext *C, /* Clear the tool-tip whenever a key binding is handled, without this tool-tips * are kept when a modal operators starts (annoying but otherwise harmless). */ - if (action & WM_HANDLER_BREAK && !ISTIMER(event->type)) { + if (action & WM_HANDLER_BREAK && !event_is_timer) { /* Window may be gone after file read. */ if (CTX_wm_window(C) != nullptr) { WM_tooltip_clear(C, CTX_wm_window(C));