macOS: end the process in on_exit so quitting doesn't crash (#117)
AccessKit's macOS adapter subclasses the window's content view and restores its class when the window is torn down; AppKit's Touch Bar support observes that view via KVO, so the next display cycle throws in -[_NSTouchBarFinderObservation invalidate] and the quit ends in a crash report. On macOS, on_exit now exits right after saving the preferences, before eframe drops the window (what eframe itself does without run_and_return). Same fix as storytold/vectorcraft#670. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9f896c1249
commit
c1d293296c
|
|
@ -51,6 +51,16 @@ impl eframe::App for App {
|
|||
}
|
||||
fn on_exit(&mut self) {
|
||||
save_prefs(&self.0);
|
||||
// macOS (#117): end the process here, before eframe tears the window down. AccessKit's
|
||||
// macOS adapter subclasses the window's content view and restores its class on teardown;
|
||||
// AppKit's Touch Bar support observes that view (KVO), so in the next display cycle
|
||||
// `-[_NSTouchBarFinderObservation invalidate]` throws "not registered" and the quit ends
|
||||
// in a crash report. eframe calls `on_exit` on every way of quitting (Quit/⌘Q, the Dock,
|
||||
// the close button, `app.quit`), and nothing after it is needed: the preferences are
|
||||
// saved and the log file is unbuffered. eframe does the same when it doesn't
|
||||
// run-and-return. `on_exit` only runs once the app exists, never on a failed start.
|
||||
#[cfg(target_os = "macos")]
|
||||
std::process::exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue