Fixed bug 3992 - SDL_GetColorKey doesn't set error message
authorSam Lantinga <slouken@libsdl.org>
Tue, 12 Dec 2017 16:37:23 -0800
changeset 11772cf9c6a79123f
parent 11771 cb68160b3ace
child 11773 83949ec5c728
Fixed bug 3992 - SDL_GetColorKey doesn't set error message

Luke A. Guest

SDL_GetColorKey does not set an error message on failure. The current source just returns -1.

The documentation https://wiki.libsdl.org/SDL_GetColorKey?highlight=%28%5CbCategoryAPI%5Cb%29%7C%28SDLFunctionTemplate%29 says to call SDL_GetError but that is useless in this case.
src/video/SDL_surface.c
     1.1 --- a/src/video/SDL_surface.c	Tue Dec 12 16:34:16 2017 -0800
     1.2 +++ b/src/video/SDL_surface.c	Tue Dec 12 16:37:23 2017 -0800
     1.3 @@ -296,11 +296,11 @@
     1.4  SDL_GetColorKey(SDL_Surface * surface, Uint32 * key)
     1.5  {
     1.6      if (!surface) {
     1.7 -        return -1;
     1.8 +        return SDL_InvalidParamError("surface");
     1.9      }
    1.10  
    1.11      if (!(surface->map->info.flags & SDL_COPY_COLORKEY)) {
    1.12 -        return -1;
    1.13 +        return SDL_SetError("Surface doesn't have a colorkey");
    1.14      }
    1.15  
    1.16      if (key) {