Skip to content

Commit abbaf95

Browse files
committed
Added macros to push/pop error messages while cleaning up
(cherry picked from commit 885e611)
1 parent 1081b70 commit abbaf95

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/SDL_internal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,12 @@ extern "C" {
265265
#include "SDL_utils_c.h"
266266
#include "SDL_hashtable.h"
267267

268+
#define PUSH_SDL_ERROR() \
269+
{ char *_error = SDL_strdup(SDL_GetError());
270+
271+
#define POP_SDL_ERROR() \
272+
SDL_SetError("%s", _error); SDL_free(_error); }
273+
268274
// Do any initialization that needs to happen before threads are started
269275
extern void SDL_InitMainThread(void);
270276

src/video/SDL_video.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2513,7 +2513,9 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props)
25132513
SDL_UpdateWindowHierarchy(window, parent);
25142514

25152515
if (_this->CreateSDLWindow && !_this->CreateSDLWindow(_this, window, props)) {
2516+
PUSH_SDL_ERROR()
25162517
SDL_DestroyWindow(window);
2518+
POP_SDL_ERROR()
25172519
return NULL;
25182520
}
25192521

0 commit comments

Comments
 (0)