Skip to content

Commit 885e611

Browse files
committed
Added macros to push/pop error messages while cleaning up
1 parent 61d1052 commit 885e611

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
@@ -2524,7 +2524,9 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props)
25242524
SDL_UpdateWindowHierarchy(window, parent);
25252525

25262526
if (_this->CreateSDLWindow && !_this->CreateSDLWindow(_this, window, props)) {
2527+
PUSH_SDL_ERROR()
25272528
SDL_DestroyWindow(window);
2529+
POP_SDL_ERROR()
25282530
return NULL;
25292531
}
25302532

0 commit comments

Comments
 (0)