bug#81510: 31.0.90; NS (macOS): clicking a disabled (:enable nil) tab-bar item crases Emacs
Alan Third <[email protected]> Thu, 30 Jul 2026 23:09:52 +0100
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Jul 30, 2026 at 08:56:13PM +0100, Al Haji-Ali wrote:
>
> On 30/07/2026, Stéphane Marks wrote:
>
> > I ran your test case with Alan's patch and it did not crash for me (or with
> > mine).
>
> I am not sure what the issue is. I applied the patch on top of
> e0d2d80a628, and I confident that the crash still happens because the
> change, as far as I can see, does not change the value being passed to
> kbd_buffer_store_event_hold.
>
> The reason w32term does not crash is because it protects against NO_EVENT here:
>
> if (inev.kind != NO_EVENT)
> {
> kbd_buffer_store_event_hold (&inev, hold_quit);
> count++;
> }
>
> In ns_term, the macro EV_TRAILER2 just checks if the event pointer
> q_event_ptr is non-nil, regardless of the value of emacs_event.kind.
So something like the attached?
--
Alan Third
v2-0001-Fix-crash-when-clicking-on-empty-tab-bar-entry-bu.patch
(text/plain, 2 KB)
From 8e2809e4e2b1e2433370e854d66ae0c0c4a3f16a Mon Sep 17 00:00:00 2001 From: Alan Third <[email protected]> Date: Wed, 29 Jul 2026 18:43:48 +0100 Subject: [PATCH v2] Fix crash when clicking on empty tab bar entry (bug#81510) * src/nsterm.m: ([EmacsView mouseDown:]): Copy order of operations regarding mouse clicks from the w32 port. (ns_read_socket_1): Don't send NO_EVENT events. --- src/nsterm.m | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index a7f3fc292c7..94345c48c2c 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5106,11 +5106,16 @@ Function modeled after x_draw_glyph_string_box (). if (hold_event_q.nr > 0) { - int i; - for (i = 0; i < hold_event_q.nr; ++i) - kbd_buffer_store_event_hold (&hold_event_q.q[i], hold_quit); + int count = 0; + for (int i = 0; i < hold_event_q.nr; ++i) + if (hold_event_q.q[i].kind != NO_EVENT) + { + kbd_buffer_store_event_hold (&hold_event_q.q[i], hold_quit); + count++; + } + hold_event_q.nr = 0; - return i; + return count; } if ([NSThread isMainThread]) @@ -7955,6 +7960,8 @@ - (void)mouseDown: (NSEvent *)theEvent Lisp_Object tab_bar_arg = Qnil; bool tab_bar_p = false; + emacs_event->kind = MOUSE_CLICK_EVENT; + if (WINDOWP (emacsframe->tab_bar_window) && WINDOW_TOTAL_LINES (XWINDOW (emacsframe->tab_bar_window))) { @@ -7971,9 +7978,12 @@ - (void)mouseDown: (NSEvent *)theEvent EV_MODIFIERS (theEvent) | EV_UDMODIFIERS (theEvent)); } - if (!(tab_bar_p && NILP (tab_bar_arg))) - emacs_event->kind = MOUSE_CLICK_EVENT; - emacs_event->arg = tab_bar_arg; + if (tab_bar_p && NILP (tab_bar_arg)) + emacs_event->kind = NO_EVENT; + + if (!NILP (tab_bar_arg)) + emacs_event->arg = tab_bar_arg; + emacs_event->code = EV_BUTTON (theEvent); emacs_event->modifiers = EV_MODIFIERS (theEvent) | EV_UDMODIFIERS (theEvent); -- 2.54.0