Fix patch after 3-reviewer pipeline review

- BLOCKER: real_this_command → Vreal_this_command (DEFVAR_LISP uses V prefix)
- Thread safety: setAccessibilitySelectedTextRange dispatches to main thread
- Defensive: 7 new BUFFERP(w->contents) guards before XBUFFER calls

Reviewed by: symbol checker, logic/memory reviewer, ABI/build reviewer
Verified: git apply --check OK, zero real_this_command refs, dispatch_async present
This commit is contained in:
2026-02-26 22:27:25 +01:00
parent 3c0a68cfb9
commit 97776b5141

View File

@@ -159,7 +159,7 @@ index 932d209..da40369 100644
ns_focus (f, NULL, 0); ns_focus (f, NULL, 0);
NSGraphicsContext *ctx = [NSGraphicsContext currentContext]; NSGraphicsContext *ctx = [NSGraphicsContext currentContext];
@@ -6849,214 +6885,1777 @@ ns_create_font_panel_buttons (id target, SEL select, SEL cancel_action) @@ -6849,214 +6885,1801 @@ ns_create_font_panel_buttons (id target, SEL select, SEL cancel_action)
/* ========================================================================== /* ==========================================================================
@@ -196,6 +196,11 @@ index 932d209..da40369 100644
+ return @""; + return @"";
+ } + }
+ +
+ if (!BUFFERP (w->contents))
+ {
+ *out_start = 0;
+ return @"";
+ }
+ struct buffer *b = XBUFFER (w->contents); + struct buffer *b = XBUFFER (w->contents);
+ if (!b) + if (!b)
+ { + {
@@ -629,7 +634,7 @@ index 932d209..da40369 100644
- NSView *buttons; - NSView *buttons;
- BOOL canceled; - BOOL canceled;
-#endif -#endif
+ if (!SYMBOLP (real_this_command)) + if (!SYMBOLP (Vreal_this_command))
+ return false; + return false;
-#ifdef NS_IMPL_GNUSTEP -#ifdef NS_IMPL_GNUSTEP
@@ -639,7 +644,7 @@ index 932d209..da40369 100644
-#endif -#endif
+ Lisp_Object next = intern ("next-line"); + Lisp_Object next = intern ("next-line");
+ Lisp_Object prev = intern ("previous-line"); + Lisp_Object prev = intern ("previous-line");
+ return EQ (real_this_command, next) || EQ (real_this_command, prev); + return EQ (Vreal_this_command, next) || EQ (Vreal_this_command, prev);
+} +}
-#ifdef NS_IMPL_COCOA -#ifdef NS_IMPL_COCOA
@@ -833,6 +838,8 @@ index 932d209..da40369 100644
+ if (!w || !WINDOW_LEAF_P (w)) + if (!w || !WINDOW_LEAF_P (w))
+ return; + return;
+ +
+ if (!BUFFERP (w->contents))
+ return;
+ struct buffer *b = XBUFFER (w->contents); + struct buffer *b = XBUFFER (w->contents);
+ if (!b) + if (!b)
+ return; + return;
@@ -1004,6 +1011,8 @@ index 932d209..da40369 100644
+ if (!w || !WINDOW_LEAF_P (w)) + if (!w || !WINDOW_LEAF_P (w))
+ return @""; + return @"";
+ +
+ if (!BUFFERP (w->contents))
+ return @"";
+ struct buffer *b = XBUFFER (w->contents); + struct buffer *b = XBUFFER (w->contents);
+ if (!b || NILP (BVAR (b, mark_active))) + if (!b || NILP (BVAR (b, mark_active)))
+ return @""; + return @"";
@@ -1022,6 +1031,8 @@ index 932d209..da40369 100644
+ if (!w || !WINDOW_LEAF_P (w)) + if (!w || !WINDOW_LEAF_P (w))
+ return NSMakeRange (0, 0); + return NSMakeRange (0, 0);
+ +
+ if (!BUFFERP (w->contents))
+ return 0;
+ struct buffer *b = XBUFFER (w->contents); + struct buffer *b = XBUFFER (w->contents);
+ if (!b) + if (!b)
+ return NSMakeRange (0, 0); + return NSMakeRange (0, 0);
@@ -1046,10 +1057,18 @@ index 932d209..da40369 100644
+ if (!w || !WINDOW_LEAF_P (w)) + if (!w || !WINDOW_LEAF_P (w))
+ return; + return;
+ +
+ struct buffer *b = XBUFFER (w->contents); + if (!BUFFERP (w->contents))
+ if (!b)
+ return; + return;
+ +
+ dispatch_async (dispatch_get_main_queue (), ^{
+ struct window *w2 = self.emacsWindow;
+ if (!w2 || !WINDOW_LEAF_P (w2))
+ return;
+
+ if (!BUFFERP (w2->contents))
+ return;
+ struct buffer *b = XBUFFER (w2->contents);
+
+ [self ensureTextCache]; + [self ensureTextCache];
+ +
+ /* Convert accessibility index to buffer charpos via mapping. */ + /* Convert accessibility index to buffer charpos via mapping. */
@@ -1064,7 +1083,7 @@ index 932d209..da40369 100644
+ block_input (); + block_input ();
+ +
+ /* Move point directly in the buffer. Use set_point_both which + /* Move point directly in the buffer. Use set_point_both which
+ operates on the current buffer temporarily switch if needed. */ + operates on the current buffer — temporarily switch if needed. */
+ struct buffer *oldb = current_buffer; + struct buffer *oldb = current_buffer;
+ if (b != current_buffer) + if (b != current_buffer)
+ set_buffer_internal_1 (b); + set_buffer_internal_1 (b);
@@ -1094,6 +1113,7 @@ index 932d209..da40369 100644
+ re-announce this movement. */ + re-announce this movement. */
+ self.cachedPoint = charpos; + self.cachedPoint = charpos;
+ self.cachedMarkActive = (range.length > 0); + self.cachedMarkActive = (range.length > 0);
+ });
+} +}
+ +
+- (void)setAccessibilityFocused:(BOOL)flag +- (void)setAccessibilityFocused:(BOOL)flag
@@ -1133,6 +1153,8 @@ index 932d209..da40369 100644
+ if (!w || !WINDOW_LEAF_P (w)) + if (!w || !WINDOW_LEAF_P (w))
+ return 0; + return 0;
+ +
+ if (!BUFFERP (w->contents))
+ return 0;
+ struct buffer *b = XBUFFER (w->contents); + struct buffer *b = XBUFFER (w->contents);
+ if (!b) + if (!b)
+ return 0; + return 0;
@@ -1367,6 +1389,8 @@ index 932d209..da40369 100644
+ if (!w || !WINDOW_LEAF_P (w)) + if (!w || !WINDOW_LEAF_P (w))
+ return; + return;
+ +
+ if (!BUFFERP (w->contents))
+ return;
+ struct buffer *b = XBUFFER (w->contents); + struct buffer *b = XBUFFER (w->contents);
+ if (!b) + if (!b)
+ return; + return;
@@ -2076,7 +2100,7 @@ index 932d209..da40369 100644
- (void)keyDown: (NSEvent *)theEvent - (void)keyDown: (NSEvent *)theEvent
{ {
@@ -8237,6 +9836,28 @@ ns_in_echo_area (void) @@ -8237,6 +9860,28 @@ ns_in_echo_area (void)
XSETFRAME (event.frame_or_window, emacsframe); XSETFRAME (event.frame_or_window, emacsframe);
kbd_buffer_store_event (&event); kbd_buffer_store_event (&event);
ns_send_appdefined (-1); // Kick main loop ns_send_appdefined (-1); // Kick main loop
@@ -2105,7 +2129,7 @@ index 932d209..da40369 100644
} }
@@ -9474,6 +11095,298 @@ ns_in_echo_area (void) @@ -9474,6 +11119,298 @@ ns_in_echo_area (void)
return fs_state; return fs_state;
} }
@@ -2404,7 +2428,7 @@ index 932d209..da40369 100644
@end /* EmacsView */ @end /* EmacsView */
@@ -9941,6 +11854,14 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) @@ -9941,6 +11878,14 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
return [super accessibilityAttributeValue:attribute]; return [super accessibilityAttributeValue:attribute];
} }