Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed bug 2344 - CHECK_WINDOW_MAGIC should include __FILE__ and __LINE__
Martin Gerhardy

just for easier debugging issues in the own code...

SDL_CreateRenderer should maybe also use this macro

Ryan C. Gordon

I'll go one better: it should have an SDL_assert().
  • Loading branch information
slouken committed Aug 14, 2017
1 parent 96e15fa commit aebe17d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/render/SDL_render.c
Expand Up @@ -33,12 +33,14 @@
#define SDL_WINDOWRENDERDATA "_SDL_WindowRenderData"

#define CHECK_RENDERER_MAGIC(renderer, retval) \
SDL_assert(renderer && renderer->magic == &renderer_magic); \
if (!renderer || renderer->magic != &renderer_magic) { \
SDL_SetError("Invalid renderer"); \
return retval; \
}

#define CHECK_TEXTURE_MAGIC(texture, retval) \
SDL_assert(texture && texture->magic == &texture_magic); \
if (!texture || texture->magic != &texture_magic) { \
SDL_SetError("Invalid texture"); \
return retval; \
Expand Down
2 changes: 2 additions & 0 deletions src/video/SDL_video.c
Expand Up @@ -130,6 +130,7 @@ static SDL_VideoDevice *_this = NULL;
SDL_UninitializedVideo(); \
return retval; \
} \
SDL_assert(window && window->magic == &_this->window_magic); \
if (!window || window->magic != &_this->window_magic) { \
SDL_SetError("Invalid window"); \
return retval; \
Expand All @@ -141,6 +142,7 @@ static SDL_VideoDevice *_this = NULL;
return retval; \
} \
SDL_assert(_this->displays != NULL); \
SDL_assert(displayIndex >= 0 && displayIndex < _this->num_displays); \
if (displayIndex < 0 || displayIndex >= _this->num_displays) { \
SDL_SetError("displayIndex must be in the range 0 - %d", \
_this->num_displays - 1); \
Expand Down

0 comments on commit aebe17d

Please sign in to comment.