From e27ab79b080e0215c2d7bf91ad5de7c2e0dce0d9 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Thu, 28 May 2026 22:55:08 +0300 Subject: [PATCH] fix(menu): wire EXIT / QUIT commands to the close path (#41) The OCS main menu's "Exit Open CAD Studio" button dispatched `Message::Command("EXIT")` but `dispatch_command` had no arm for it, so the click was swallowed. Route `EXIT` and `QUIT` through `Message::WindowCloseRequested` so the unsaved-changes dialog runs first and the app then exits via the same path as the OS-window close. Closes #41 Co-Authored-By: Claude Opus 4.7 --- src/app/commands.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/commands.rs b/src/app/commands.rs index 009890aa1..45fcfa243 100644 --- a/src/app/commands.rs +++ b/src/app/commands.rs @@ -32,6 +32,15 @@ impl OpenCADStudio { "CLEAR" | "CLR" => return Task::done(Message::ClearScene), "WIREFRAME" | "VW" => return Task::done(Message::SetWireframe(true)), "SOLID" | "VS" => return Task::done(Message::SetWireframe(false)), + "EXIT" | "QUIT" => { + // Funnel through the OS close path so the unsaved-changes + // dialog runs before `iced::exit()`. Falls back to a hard + // exit if there's no main window registered yet. + if let Some(id) = self.main_window { + return Task::done(Message::WindowCloseRequested(id)); + } + return iced::exit(); + } // ── Background color ─────────────────────────────────────────── // Usage: BACKGROUND (0–255 each)