SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Using ShowMessageBox and GetError in the examples breaks on X11

Open ritalat opened this issue 1 year ago • 2 comments

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()).

ritalat avatar Sep 23 '24 18:09 ritalat

(and also I guess the examples should log on video init failure instead of trying to show a message box)

ritalat avatar Sep 23 '24 18:09 ritalat

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.

smcv avatar Sep 25 '24 11:09 smcv

So #11655 will fix this completely, but we have also removed the message boxes from the example apps.

icculus avatar Dec 17 '24 00:12 icculus