From bdefb88b2b71910436a3c78237c503c8b62b4ced Mon Sep 17 00:00:00 2001 From: Daniel Colascione Date: Tue, 10 Jun 2025 19:49:04 -0700 Subject: [PATCH] Fix lost C-g events in NS port under load The NS port was incorrectly reading input events in ns_flush_display, storing them in a local variable that was never processed. This caused C-g (quit) events to be lost when Emacs was under heavy load, making it difficult to interrupt long-running operations. * src/nsterm.m (ns_flush_display): Pass NULL instead of a local variable to ns_read_socket_1, ensuring events are processed normally instead of being discarded. * etc/NEWS: Announce the fix. --- etc/NEWS | 5 +++++ src/nsterm.m | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 90b9c7ea9a2..b1f349cc3e5 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2001,6 +2001,11 @@ determined by the new user option 'pulse-face-duration'. ** Miscellaneous +--- +*** Fixed lost C-g events on NS port under heavy load. +The NS port now no longer loses quits when redisplay happens frequently, +for example, during certain kinds of heavy IO load. + --- *** 'tooltip-mode' now shows tooltips after delay on TTY frames. Display of tooltips on text-only terminals now happens after diff --git a/src/nsterm.m b/src/nsterm.m index 003aadb9782..59728aa11b0 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5487,10 +5487,10 @@ ns_update_window_end (struct window *w, bool cursor_on_p, static void ns_flush_display (struct frame *f) { - struct input_event ie; - - EVENT_INIT (ie); - ns_read_socket_1 (FRAME_TERMINAL (f), &ie, YES); + /* Must pass NULL for hold_quit: otherwise, + we lose quits under load because we discard what ends + up in hold_quit. */ + ns_read_socket_1 (FRAME_TERMINAL (f), NULL, YES); } /* This and next define (many of the) public functions in this