From 3ad0966590cd3cf3ed75f65bd4f495a3dac34beb Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 21 Jun 2023 23:22:47 +1000 Subject: [PATCH] macOS: Add option for not showing dialogs, and revert the try/catch for showing dialog --- src/_WindowBase.h | 2 ++ src/interop_cocoa.m | 10 +++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/_WindowBase.h b/src/_WindowBase.h index e6e1796fc..d59a67a7e 100644 --- a/src/_WindowBase.h +++ b/src/_WindowBase.h @@ -15,6 +15,7 @@ int Display_ScaleY(int y) { return (int)(y * DisplayInfo.ScaleY); } static int cursorPrevX, cursorPrevY; static cc_bool cursorVisible = true; +static cc_bool showDialogs = true; /* Gets the position of the cursor in screen or window coordinates */ static void Cursor_GetRawPos(int* x, int* y); /* Sets whether the cursor is visible when over this window */ @@ -64,6 +65,7 @@ static void ShowDialogCore(const char* title, const char* msg); void Window_ShowDialog(const char* title, const char* msg) { /* Ensure cursor is usable while showing message box */ cc_bool rawMode = Input_RawMode; + if (!showDialogs) return; if (rawMode) Window_DisableRawMouse(); ShowDialogCore(title, msg); diff --git a/src/interop_cocoa.m b/src/interop_cocoa.m index e40456874..3c43653e3 100644 --- a/src/interop_cocoa.m +++ b/src/interop_cocoa.m @@ -150,6 +150,7 @@ static void LogUnhandledNSErrors(NSException* ex) { static NSAutoreleasePool* pool; void Window_Init(void) { NSSetUncaughtExceptionHandler(LogUnhandledNSErrors); + showDialogs = Options_GetBool("show-dialogs", true); // https://www.cocoawithlove.com/2009/01/demystifying-nsapplication-by.html pool = [[NSAutoreleasePool alloc] init]; @@ -546,13 +547,8 @@ void ShowDialogCore(const char* title, const char* msg) { titleCF = CFStringCreateWithCString(NULL, title, kCFStringEncodingASCII); msgCF = CFStringCreateWithCString(NULL, msg, kCFStringEncodingASCII); - // backwards compatible @try @catch - NS_DURING { - alert = [NSAlert alloc]; - alert = [alert init]; - } NS_HANDLER { - LogUnhandledNSErrors(localException); - } NS_ENDHANDLER + alert = [NSAlert alloc]; + alert = [alert init]; [alert setMessageText: titleCF]; [alert setInformativeText: msgCF];