Fixed bug #761
authorSam Lantinga <slouken@libsdl.org>
Sat, 26 Sep 2009 10:13:44 +0000
changeset 331587ffdad11607
parent 3314 8b01b0648f01
child 3316 9cf18687b761
Fixed bug #761

Mason Wheeler 2009-07-05 09:28:33 PDT

This patch fixes two issues with SDL_CreateTextureFromSurface.

1. If no renderer is available, the function will return 0 without calling
SDL_SetError. (It does this in other places as well, but it appears that in
these cases, SDL_SetError was already called by a previous function call.)
2. Removal of a dead code block that checks for an impossible return value.
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_video.c	Sat Sep 26 10:04:38 2009 +0000
     1.2 +++ b/src/video/SDL_video.c	Sat Sep 26 10:13:44 2009 +0000
     1.3 @@ -1596,6 +1596,7 @@
     1.4  
     1.5      renderer = SDL_CurrentDisplay.current_renderer;
     1.6      if (!renderer) {
     1.7 +        SDL_SetError("No current renderer available");
     1.8          return 0;
     1.9      }
    1.10  
    1.11 @@ -1815,10 +1816,7 @@
    1.12      if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask
    1.13          && Bmask == fmt->Bmask && Amask == fmt->Amask) {
    1.14          if (SDL_MUSTLOCK(surface)) {
    1.15 -            if (SDL_LockSurface(surface) < 0) {
    1.16 -                SDL_DestroyTexture(textureID);
    1.17 -                return 0;
    1.18 -            }
    1.19 +            SDL_LockSurface(surface);
    1.20              SDL_UpdateTexture(textureID, NULL, surface->pixels,
    1.21                                surface->pitch);
    1.22              SDL_UnlockSurface(surface);