macOS: Quit (Cmd+Q), the Dock's Quit and logout ask to save unsaved drawings (#2157) (#2620)

Quit CADCraft in the app menu, the Dock's Quit and logout end the app through AppKit's
terminate, which skipped the "Save changes to ...?" prompt, so unsaved work was lost. The
event loop now turns termination into a close request for the window (the storytold winit
fork's opt-in, as DesignCraft does), so it asks first, as the close button does. Cancel keeps
the app open; Force Quit can't be intercepted.

Co-authored-by: Ethan Dale <ethandale@Ethans-MacBook-Pro.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elarionus
2026-11-02 14:26:04 -07:00
committed by GitHub
co-authored by Ethan Dale Claude Opus 5.5
parent ed08716f30
commit f4c68e18fc
2 changed files with 13 additions and 0 deletions
+3
View File
@@ -50,6 +50,9 @@ muda = { version = "0.21", default-features = false }
# View ▸ Accessibility ▸ Animation Effects ▸ Use System Setting: the system's Reduce motion
# (system_animations.rs). Already in Cargo.lock through muda.
objc2-app-kit = { version = "0.3", default-features = false, features = ["std", "NSWorkspace", "NSAccessibility"] }
# The same winit eframe uses (the storytold fork, patched in the workspace): its opt-in that turns
# AppKit's terminate (Cmd+Q, Dock Quit) into a close request, so unsaved changes are asked about.
winit = { version = "0.30", default-features = false }
# Rust HID backends: no proprietary SDK or C HID library.
[target.'cfg(target_os = "windows")'.dependencies]
+10
View File
@@ -310,6 +310,16 @@ fn main() -> eframe::Result {
b.with_x11();
}));
}
// macOS: Quit CADCraft (Cmd+Q), the Dock's Quit and logout end the app through AppKit's
// terminate, which would skip the unsaved-changes prompt (#2157). winit turns each into a
// close request for the window instead, so it asks first, as the close button does.
#[cfg(target_os = "macos")]
{
options.event_loop_builder = Some(Box::new(|b| {
use winit::platform::macos::EventLoopBuilderExtMacOS;
b.with_close_requested_on_terminate(true);
}));
}
eframe::run_native(
"CADCraft",
options,