diff --git a/src/app/core/platform/app_delegate.h b/src/app/core/platform/app_delegate.h index 159aa3d7..a1e4aa56 100644 --- a/src/app/core/platform/app_delegate.h +++ b/src/app/core/platform/app_delegate.h @@ -51,7 +51,7 @@ void yaze_initialize_cocoa(); /** * @brief Run the Cocoa application delegate. */ -void yaze_run_cocoa_app_delegate(const char *filename); +int yaze_run_cocoa_app_delegate(const char *filename); #ifdef __cplusplus } // extern "C" diff --git a/src/app/core/platform/app_delegate.mm b/src/app/core/platform/app_delegate.mm index 7c0237ac..de33e70e 100644 --- a/src/app/core/platform/app_delegate.mm +++ b/src/app/core/platform/app_delegate.mm @@ -236,20 +236,26 @@ extern "C" void yaze_initialize_cococa() { } } -extern "C" void yaze_run_cocoa_app_delegate(const char *filename) { +extern "C" int yaze_run_cocoa_app_delegate(const char *filename) { yaze_initialize_cococa(); yaze::core::Controller controller; - RETURN_VOID_IF_ERROR(controller.OnEntry(filename)); + EXIT_IF_ERROR(controller.OnEntry(filename)); while (controller.IsActive()) { @autoreleasepool { controller.OnInput(); if (auto status = controller.OnLoad(); !status.ok()) { + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText:@"Error"]; + [alert setInformativeText:[NSString stringWithUTF8String:status.message().data()]]; + [alert addButtonWithTitle:@"OK"]; + [alert runModal]; break; } controller.DoRender(); } } controller.OnExit(); + return EXIT_SUCCESS; } #endif diff --git a/src/app/main.cc b/src/app/main.cc index b4ee0bb1..fcc98872 100644 --- a/src/app/main.cc +++ b/src/app/main.cc @@ -32,8 +32,7 @@ int main(int argc, char** argv) { } #ifdef __APPLE__ - yaze_run_cocoa_app_delegate(rom_filename.c_str()); - return EXIT_SUCCESS; + return yaze_run_cocoa_app_delegate(rom_filename.c_str()); #elif defined(_WIN32) // We set SDL_MAIN_HANDLED for Win32 to avoid SDL hijacking main() SDL_SetMainReady();