Fixed bug 2344 - CHECK_WINDOW_MAGIC should include __FILE__ and __LINE__
authorSam Lantinga <slouken@libsdl.org>
Mon, 14 Aug 2017 16:34:54 -0700
changeset 11294593a22326cbf
parent 11293 2759ce803a47
child 11295 f926311278e8
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().
src/render/SDL_render.c
src/video/SDL_video.c
     1.1 --- a/src/render/SDL_render.c	Mon Aug 14 16:09:44 2017 -0700
     1.2 +++ b/src/render/SDL_render.c	Mon Aug 14 16:34:54 2017 -0700
     1.3 @@ -33,12 +33,14 @@
     1.4  #define SDL_WINDOWRENDERDATA    "_SDL_WindowRenderData"
     1.5  
     1.6  #define CHECK_RENDERER_MAGIC(renderer, retval) \
     1.7 +    SDL_assert(renderer && renderer->magic == &renderer_magic); \
     1.8      if (!renderer || renderer->magic != &renderer_magic) { \
     1.9          SDL_SetError("Invalid renderer"); \
    1.10          return retval; \
    1.11      }
    1.12  
    1.13  #define CHECK_TEXTURE_MAGIC(texture, retval) \
    1.14 +    SDL_assert(texture && texture->magic == &texture_magic); \
    1.15      if (!texture || texture->magic != &texture_magic) { \
    1.16          SDL_SetError("Invalid texture"); \
    1.17          return retval; \
     2.1 --- a/src/video/SDL_video.c	Mon Aug 14 16:09:44 2017 -0700
     2.2 +++ b/src/video/SDL_video.c	Mon Aug 14 16:34:54 2017 -0700
     2.3 @@ -130,6 +130,7 @@
     2.4          SDL_UninitializedVideo(); \
     2.5          return retval; \
     2.6      } \
     2.7 +    SDL_assert(window && window->magic == &_this->window_magic); \
     2.8      if (!window || window->magic != &_this->window_magic) { \
     2.9          SDL_SetError("Invalid window"); \
    2.10          return retval; \
    2.11 @@ -141,6 +142,7 @@
    2.12          return retval; \
    2.13      } \
    2.14      SDL_assert(_this->displays != NULL); \
    2.15 +    SDL_assert(displayIndex >= 0 && displayIndex < _this->num_displays); \
    2.16      if (displayIndex < 0 || displayIndex >= _this->num_displays) { \
    2.17          SDL_SetError("displayIndex must be in the range 0 - %d", \
    2.18                       _this->num_displays - 1); \