Save and restore error messages when rolling back after failed init
Fixes https://github.com/libsdl-org/SDL/issues/12439
This commit is contained in:
parent
2c46c3d5b7
commit
1a7c206986
2 changed files with 27 additions and 1 deletions
|
@ -46,4 +46,16 @@ typedef struct SDL_error
|
|||
// Defined in SDL_thread.c
|
||||
extern SDL_error *SDL_GetErrBuf(bool create);
|
||||
|
||||
// Macros to save and restore error values
|
||||
#define SDL_PushError() \
|
||||
char *saved_error = SDL_strdup(SDL_GetError())
|
||||
|
||||
#define SDL_PopError() \
|
||||
do { \
|
||||
if (saved_error) { \
|
||||
SDL_SetError("%s", saved_error); \
|
||||
SDL_free(saved_error); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif // SDL_error_c_h_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue