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 - Patch: 2 SDL_CreateTextureFromSurface fixes
Summary: Patch: 2 SDL_CreateTextureFromSurface fixes
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86 Windows Vista
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-05 09:28 UTC by Mason Wheeler
Modified: 2009-09-26 03:13 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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!