SDL: Don't clobber the error in SDL_ShowMessageBox() if one has been set at

From 98c983628726359ee2ccb9053b394fb0e04dbb8f Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 10 Nov 2021 11:04:51 -0800
Subject: [PATCH] Don't clobber the error in SDL_ShowMessageBox() if one has
 been set at the platform level

Fixes https://github.com/libsdl-org/SDL/issues/4760
---
 src/video/SDL_video.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index af9302be4f..4404d963e9 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -4271,6 +4271,8 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
     if (!mbdata.message) mbdata.message = "";
     messageboxdata = &mbdata;
 
+    SDL_ClearError();
+
     if (_this && _this->ShowMessageBox) {
         retval = _this->ShowMessageBox(_this, messageboxdata, buttonid);
     }
@@ -4352,7 +4354,11 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
     }
 #endif
     if (retval == -1) {
-        SDL_SetError("No message system available");
+        const char *error = SDL_GetError();
+
+        if (!*error) {
+            SDL_SetError("No message system available");
+        }
     }
 
     if (current_window) {