| Summary: | SDL_ShowMessageBox displays different error from intended | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Mark Callow <libsdl.org> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | iPhone/iPod touch | ||
| OS: | Other | ||
| Attachments: | Fix to avoid stomping on existing errors | ||
Created attachment 2788 [details] Fix to avoid stomping on existing errors The proper fix is in the attached patch. It changes SDL_SetError to use SDL_GetErrorMsg instead of SDL_GetError. The fix is included in the Vulkan support in bug #3591 because this bug was screwing up my error messages while I was working on that one. Fixed, thanks! https://hg.libsdl.org/SDL/rev/15f027d062f8 |
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.