mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 16:45:32 +00:00
Fixed bug 3696 - SDL_ShowMessageBox displays different error from intended
Mark Callow SDL_ShowMessageBox calls SDL_CaptureMouse which, in the UIKit driver, raises a ?That operation is not supported? error, overwriting the SDL error that an application may be trying to report. This is because UIKit SDL_CaptureMouse returns SDL_Unsupported() which ends up calling SDL_SetError() which has the following code: /* If we are in debug mode, print out an error message */ SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", SDL_GetError()); The SDL_GetError call here overwrites the static buffer?.. Although an application can avoid this by using SDL_GetErrorMsg(char* errstr, int maxlen) to avoid the static buffer, SDL should be fixed. The fix is simple. In SDL_SetError change SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", SDL_GetError()); to SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", error); where error is the pointer to the buffer where it assembled the message.
This commit is contained in:
parent
37722d01a8
commit
cd79d8ccec
|
@ -49,6 +49,8 @@ SDL_LookupString(const char *key)
|
||||||
|
|
||||||
/* Public functions */
|
/* Public functions */
|
||||||
|
|
||||||
|
static char *SDL_GetErrorMsg(char *errstr, int maxlen);
|
||||||
|
|
||||||
int
|
int
|
||||||
SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
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);
|
va_end(ap);
|
||||||
|
|
||||||
/* If we are in debug mode, print out an error message */
|
if (SDL_LogGetPriority(SDL_LOG_CATEGORY_ERROR) <= SDL_LOG_PRIORITY_DEBUG) {
|
||||||
SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", SDL_GetError());
|
/* 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *SDL_GetErrorMsg(char *errstr, int maxlen);
|
|
||||||
|
|
||||||
/* Available for backwards compatibility */
|
/* Available for backwards compatibility */
|
||||||
const char *
|
const char *
|
||||||
SDL_GetError(void)
|
SDL_GetError(void)
|
||||||
|
|
Loading…
Reference in a new issue