From a5405e56449e90203db909ea4ed1b19500e5044b Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 19 Sep 2022 09:35:58 +0800 Subject: [PATCH] Fix GC protection of scroll bar windows * src/xterm.c (x_atom_refs): Add _EMACS prefix to vendor-specific scroll-bar atoms. (handle_one_xevent): Unprotect windows immediately upon receiving an _EMACS_SCROLLBAR event, instead of waiting for the event to be put on the keyboard buffer. Reported by martin rudalics . --- src/xterm.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index cb6581b78cf..245306c67c8 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -970,8 +970,8 @@ static const struct x_atom_ref x_atom_refs[] = /* Ghostscript support. */ ATOM_REFS_INIT ("DONE", Xatom_DONE) ATOM_REFS_INIT ("PAGE", Xatom_PAGE) - ATOM_REFS_INIT ("SCROLLBAR", Xatom_Scrollbar) - ATOM_REFS_INIT ("HORIZONTAL_SCROLLBAR", Xatom_Horizontal_Scrollbar) + ATOM_REFS_INIT ("_EMACS_SCROLLBAR", Xatom_Scrollbar) + ATOM_REFS_INIT ("_EMACS_HORIZONTAL_SCROLLBAR", Xatom_Horizontal_Scrollbar) ATOM_REFS_INIT ("_XEMBED", Xatom_XEMBED) /* EWMH */ ATOM_REFS_INIT ("_NET_WM_STATE", Xatom_net_wm_state) @@ -18103,12 +18103,24 @@ handle_one_xevent (struct x_display_info *dpyinfo, if (event->xclient.message_type == dpyinfo->Xatom_Scrollbar) { x_scroll_bar_to_input_event (event, &inev.ie); + + /* Unprotect the first window to be sent in a + ClientMessage event, since it is now on the stack and + thereby subject to garbage collection. */ + x_unprotect_window_for_callback (dpyinfo); + *finish = X_EVENT_GOTO_OUT; goto done; } else if (event->xclient.message_type == dpyinfo->Xatom_Horizontal_Scrollbar) { x_horizontal_scroll_bar_to_input_event (event, &inev.ie); + + /* Unprotect the first window to be sent in a + ClientMessage event, since it is now on the stack and + thereby subject to garbage collection. */ + x_unprotect_window_for_callback (dpyinfo); + *finish = X_EVENT_GOTO_OUT; goto done; } @@ -23709,12 +23721,6 @@ handle_one_xevent (struct x_display_info *dpyinfo, count++; } -#ifdef USE_TOOLKIT_SCROLL_BARS - if (event->xany.type == ClientMessage - && inev.ie.kind == SCROLL_BAR_CLICK_EVENT) - x_unprotect_window_for_callback (dpyinfo); -#endif - if (do_help && !(hold_quit && hold_quit->kind != NO_EVENT)) { -- 2.39.2