From 6367ffa5a9b2809158cb4423e9e4a2f4eea93bb4 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Wed, 6 May 2020 11:38:38 +0200 Subject: [PATCH] GFX2_MessageBox(): Doxygen + fix return code --- src/screen.h | 5 +++++ src/sdlscreen.c | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/screen.h b/src/screen.h index 09a09de4..1cf3181d 100644 --- a/src/screen.h +++ b/src/screen.h @@ -114,6 +114,11 @@ int GFX2_GetScreenSize(int * width, int * height); /** * Display a modal message + * + * @param text body of the modal message + * @param caption title of the message + * @param type one of GFX2_MB_INFO, GFX2_MB_ERROR, GFX2_MB_WARNING + * @return 0 for error */ int GFX2_MessageBox(const char * text, const char * caption, unsigned int type); diff --git a/src/sdlscreen.c b/src/sdlscreen.c index f04192dc..bf1b50fc 100644 --- a/src/sdlscreen.c +++ b/src/sdlscreen.c @@ -803,7 +803,16 @@ void Set_mouse_position(void) int GFX2_MessageBox(const char * text, const char * caption, unsigned int type) { #if defined(USE_SDL2) - return SDL_ShowSimpleMessageBox(type, caption, text, Window_SDL); + // SDL_ShowSimpleMessageBox() returns 0 on success + if (SDL_ShowSimpleMessageBox(type, caption, text, Window_SDL) == 0) + { + return 1; + } + else + { + GFX2_Log(GFX2_ERROR, "SDL_ShowSimpleMessageBox() failed : %s\n", SDL_GetError()); + return 0; + } #elif defined(WIN32) return MessageBoxA(GFX2_Get_Window_Handle(), text, caption, type); #elif defined(__macosx__) @@ -817,6 +826,7 @@ int GFX2_MessageBox(const char * text, const char * caption, unsigned int type) NULL, NULL, NULL, &result); CFRelease(text_ref); CFRelease(caption_ref); + // CFUserNotificationDisplayAlert() returns 0 on success return (r == 0); #else return 0;