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 4264

Summary: SDL_CreateTextureFromSurface generates error message but returns ok
Product: SDL Reporter: Anthony @ POW Games <ant>
Component: renderAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2 CC: sezeroz, sylvain.becker
Version: 2.0.8   
Hardware: All   
OS: All   

Description Anthony @ POW Games 2018-09-20 10:14:01 UTC
SDL_CreateTextureFromSurface makes an internal call to SDL_GetColorKey which can return an error and spams the error log with "Surface doesn't have a colorkey" even though the original function didn't return an error.
Comment 1 Anthony @ POW Games 2018-09-20 10:15:04 UTC
This only started since 2.0.8
Comment 2 Sam Lantinga 2018-09-24 23:43:03 UTC
Generally you should ignore any error message if the function you're calling doesn't return a failure.

However, I went ahead and added an API function to fix this:
https://hg.libsdl.org/SDL/rev/5486557ca8d9
Comment 3 Sylvain 2018-09-25 08:51:37 UTC
Hi,

In file src/render/SDL_render.c, no need of

-    if (fmt->Amask || SDL_GetColorKey(surface, NULL) == 0) {
+    if (fmt->Amask || (SDL_HasColorKey(surface) && SDL_GetColorKey(surface, NULL) == 0)) {

because GetColorKey is not used to retrieve the color key, so only: 

-    if (fmt->Amask || SDL_GetColorKey(surface, NULL) == 0) {
+    if (fmt->Amask || SDL_HasColorKey(surface)) {
Comment 4 Sam Lantinga 2018-09-26 02:54:04 UTC
Oh good catch, thanks!
https://hg.libsdl.org/SDL/rev/90162273424f