SDL
SDL copied to clipboard
Using ShowMessageBox and GetError in the examples breaks on X11
Right now ShowMessageBox always tries to create a Wayland message box before X11 one and in the process ends up calling SetError.
The official SDL examples pass the return value of GetError directly to ShowMessageBox and end up giving nonsensical errors. For example running SDL_RENDER_DRIVER=invalid ./renderer-scaling-textures gives you an error box saying "Not on a wayland display" on X11.
Should SDL_ShowMessageBox guarantee to never call SDL_SetError internally or should the user be required to create a copy of the error message before passing it? The documentation does indicate that error will be set but even the official examples seem to wish that it was as convenient as calling SDL_Log("%s", SDL_GetError()).
(and also I guess the examples should log on video init failure instead of trying to show a message box)
This is reminding me of errno, which similarly needs saving when your error-handling can end up changing errno itself - except more so, because the string from SDL_GetError() needs copying, not just assignment.
So #11655 will fix this completely, but we have also removed the message boxes from the example apps.