| Summary: | Patch: 2 SDL_CreateTextureFromSurface fixes | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Mason Wheeler <masonwheeler> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | x86 | ||
| OS: | Windows Vista | ||
This patch is in subversion, thanks! |
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. Patch: Index: SDL_video.c =================================================================== --- SDL_video.c (revision 4599) +++ SDL_video.c (working copy) @@ -1617,6 +1617,7 @@ renderer = SDL_CurrentDisplay.current_renderer; if (!renderer) { + SDL_SetError("No current renderer available"); return 0; } @@ -1836,10 +1837,7 @@ if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask && Bmask == fmt->Bmask && Amask == fmt->Amask) { if (SDL_MUSTLOCK(surface)) { - if (SDL_LockSurface(surface) < 0) { - SDL_DestroyTexture(textureID); - return 0; - } + SDL_LockSurface(surface); SDL_UpdateTexture(textureID, NULL, surface->pixels, surface->pitch); SDL_UnlockSurface(surface);