From 157dd4a647f96a8a7642a50e4fc3e94b6d9cd055 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Wed, 15 Oct 2025 19:52:21 +0200 Subject: [PATCH] Implement save_and_quit for macos --- base/sources/backends/macos_system.m | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/base/sources/backends/macos_system.m b/base/sources/backends/macos_system.m index 4b6063da..1dc4020a 100644 --- a/base/sources/backends/macos_system.m +++ b/base/sources/backends/macos_system.m @@ -1184,6 +1184,34 @@ void deviceRemoved(void *inContext, IOReturn inResult, void *inSender, IOHIDDevi #endif +extern void (*iron_save_and_quit)(bool); + +bool _save_and_quit_callback_internal() { + bool save = false; + NSString *title = [window title]; + bool dirty = [title rangeOfString:@"* - ArmorPaint"].location != NSNotFound; + if (dirty) { + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText:@"Project has been modified, save changes?"]; + [alert addButtonWithTitle:@"Yes"]; + [alert addButtonWithTitle:@"Cancel"]; + [alert addButtonWithTitle:@"No"]; + [alert setAlertStyle:NSAlertStyleWarning]; + NSInteger res = [alert runModal]; + if (res == NSAlertFirstButtonReturn) { + save = true; + } + else if (res == NSAlertThirdButtonReturn) { + save = false; + } + else { // Cancel + return false; + } + } + iron_save_and_quit(save); + return false; +} + volatile int iron_exec_async_done = 1; void iron_exec_async(const char *path, char *argv[]) {}