Files
semmelrinde 8ced905843 macOS: quitting on a Mac with a Touch Bar no longer crashes (#7535) (#7762)
* claim: #7535

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Vendor accesskit_macos 0.26.3 as published (#7535)

The published package, unchanged, so the next commit shows the fix as a diff.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* macOS: quitting on a Mac with a Touch Bar no longer crashes (#7535)

eframe's accessibility adapter (accesskit_macos 0.26.3) swaps the window's
view to a subclass of its own. When AppKit's Touch Bar observes the first
responder (nextResponder), key-value observing subclasses the view again.
Dropping the adapter on quit reset the view's class, which threw away KVO's
subclass, so AppKit's removal of its observer raised NSRangeException ("not
registered as an observer") and the app ended with EXC_BREAKPOINT.

accesskit_macos 0.27.2 fixes this (AccessKit/accesskit#835), but egui 0.36
is on accesskit 0.24, so vendor 0.26.3 with 0.27.2's src/subclass.rs and its
tests: the adapter leaves the class alone when KVO subclassed the view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 13:35:37 +00:00

50 lines
1.2 KiB
Rust

// Copyright 2026 The AccessKit Authors. All rights reserved.
// Licensed under the Apache License, Version 2.0 (found in
// the LICENSE-APACHE file) or the MIT license (found in
// the LICENSE-MIT file), at your option.
use std::{cell::Cell, rc::Rc};
use accesskit::{ActionHandler, ActionRequest, ActivationHandler, TreeUpdate};
use objc2::rc::Id;
use objc2::runtime::AnyObject;
use objc2::{class, msg_send_id};
use objc2_app_kit::NSView;
#[derive(Default)]
pub struct HandlerEvents {
pub tree_requested: Cell<bool>,
pub dropped: Cell<bool>,
}
pub struct NoTree(pub Rc<HandlerEvents>);
impl ActivationHandler for NoTree {
fn request_initial_tree(&mut self) -> Option<TreeUpdate> {
self.0.tree_requested.set(true);
None
}
}
impl Drop for NoTree {
fn drop(&mut self) {
self.0.dropped.set(true);
}
}
pub struct NoActions;
impl ActionHandler for NoActions {
fn do_action(&mut self, _request: ActionRequest) {}
}
pub fn new_view() -> Id<NSView> {
unsafe { msg_send_id![class!(NSView), new] }
}
// KVO overrides the `class` method to hide its own subclass.
pub fn class_name(view: &NSView) -> String {
let object: &AnyObject = view;
object.class().name().to_owned()
}