From 761631c56cc99ec394f3047fc99bbc059e709283 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Fri, 9 Oct 2026 08:19:34 -0400 Subject: [PATCH] Quit from the macOS menu: save settings and the library (and honour the unsaved-changes prompt) before exiting std::process::exit skipped eframe's on_exit (ui.json, close_library) and the may_close check, so changes still in memory could be lost on Cmd+Q. Co-Authored-By: Claude Opus 5.5 --- apps/lightcraft/src/main.rs | 11 +++++++++-- apps/lightcraft/src/native_menu.rs | 13 +++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/apps/lightcraft/src/main.rs b/apps/lightcraft/src/main.rs index a0394da9..aedbf7fb 100644 --- a/apps/lightcraft/src/main.rs +++ b/apps/lightcraft/src/main.rs @@ -52,8 +52,15 @@ struct App(LightcraftApp, PrefsWriter, #[cfg(target_os = "macos")] Option bool { lightcraft_ui_egui::i18n::set_language(app.ui.language); + let mut quit = false; while let Ok(key) = self.rx.try_recv() { if key == QUIT { - std::process::exit(0); + quit = true; + continue; } if key == "app.about" || key == SETTINGS { let _ = app.run(&key, serde_json::json!({})); @@ -374,7 +378,7 @@ impl NativeMenu { let bar = menu_bar(app); if structure_of(&bar) != self.structure { self.rebuild(app); - return; + return quit; } fn walk(nodes: &[MenuNode], items: &mut HashMap) { for n in nodes { @@ -428,6 +432,7 @@ impl NativeMenu { } self.publish_shortcuts(app); } + quit } }