We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 761

Summary: Patch: 2 SDL_CreateTextureFromSurface fixes
Product: SDL Reporter: Mason Wheeler <masonwheeler>
Component: videoAssignee: 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   

Description Mason Wheeler 2009-07-05 09:28:33 UTC
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);
Comment 1 Sam Lantinga 2009-09-26 03:13:56 UTC
This patch is in subversion, thanks!