v13 patch: fix MRC retain/release for accessibilityElements array

- arrayWithCapacity: returns autorelease object, must retain for ivar
- Release old array before reassigning in rebuildAccessibilityTree
- Release in EmacsView dealloc
- Fixes crash: _NSPasteboardTypeCache countByEnumeratingWithState (dangling pointer)
This commit is contained in:
2026-02-26 08:52:46 +01:00
parent e152900004
commit e5bfce500f

View File

@@ -12,6 +12,7 @@ New classes:
EmacsView becomes an AXGroup containing EmacsAccessibilityBuffer children.
Notification hooks fire on cursor movement, text edits, and window changes.
Uses unsafe_unretained references (MRC compatible) and proper retain/release.
---
--- a/src/nsterm.h 2026-02-26 08:46:18.118172281 +0100
+++ b/src/nsterm.h 2026-02-26 08:46:06.891980688 +0100
@@ -73,7 +74,7 @@ Notification hooks fire on cursor movement, text edits, and window changes.
--- a/src/nsterm.m 2026-02-26 08:46:18.124172384 +0100
+++ b/src/nsterm.m 2026-02-26 08:46:06.895980756 +0100
+++ b/src/nsterm.m 2026-02-26 08:52:18.397374436 +0100
@@ -1104,6 +1104,11 @@
unblock_input ();
@@ -697,7 +698,15 @@ Notification hooks fire on cursor movement, text edits, and window changes.
EmacsView implementation
========================================================================== */
@@ -9474,6 +10083,143 @@
@@ -6889,6 +7498,7 @@
[layer release];
#endif
+ [accessibilityElements release];
[[self menu] release];
[super dealloc];
}
@@ -9474,6 +10084,144 @@
return fs_state;
}
@@ -753,7 +762,8 @@ Notification hooks fire on cursor movement, text edits, and window changes.
+ NSMutableArray *newElements = [NSMutableArray arrayWithCapacity:4];
+ Lisp_Object root = FRAME_ROOT_WINDOW (emacsframe);
+ ns_ax_collect_windows (root, self, newElements);
+ accessibilityElements = newElements;
+ [accessibilityElements release];
+ accessibilityElements = [newElements retain];
+}
+
+- (NSAccessibilityRole)accessibilityRole
@@ -841,7 +851,7 @@ Notification hooks fire on cursor movement, text edits, and window changes.
@end /* EmacsView */
@@ -9941,6 +10687,14 @@
@@ -9941,6 +10689,14 @@
return [super accessibilityAttributeValue:attribute];
}