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 - SDL_CreateTextureFromSurface generates error message but returns ok
Summary: SDL_CreateTextureFromSurface generates error message but returns ok
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: 2.0.8
Hardware: All All
: P2 minor
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-20 10:14 UTC by Anthony @ POW Games
Modified: 2018-09-26 02:54 UTC (History)
2 users (show)

See Also:


Attachments

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