|
@@ -49,6 +49,8 @@ SDL_LookupString(const char *key)
|
|
|
|
|
|
/* Public functions */
|
|
|
|
|
|
+static char *SDL_GetErrorMsg(char *errstr, int maxlen);
|
|
|
+
|
|
|
int
|
|
|
SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
|
|
{
|
|
@@ -110,14 +112,19 @@ SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
|
|
}
|
|
|
va_end(ap);
|
|
|
|
|
|
- /* If we are in debug mode, print out an error message */
|
|
|
- SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", SDL_GetError());
|
|
|
-
|
|
|
+ if (SDL_LogGetPriority(SDL_LOG_CATEGORY_ERROR) <= SDL_LOG_PRIORITY_DEBUG) {
|
|
|
+ /* If we are in debug mode, print out an error message
|
|
|
+ * Avoid stomping on the static buffer in GetError, just
|
|
|
+ * in case this is called while processing a ShowMessageBox to
|
|
|
+ * show an error already in that static buffer.
|
|
|
+ */
|
|
|
+ char errmsg[SDL_ERRBUFIZE];
|
|
|
+ SDL_GetErrorMsg(errmsg, sizeof(errmsg));
|
|
|
+ SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", errmsg);
|
|
|
+ }
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
-static char *SDL_GetErrorMsg(char *errstr, int maxlen);
|
|
|
-
|
|
|
/* Available for backwards compatibility */
|
|
|
const char *
|
|
|
SDL_GetError(void)
|