Skip to content

Commit 1ff5ac1

Browse files
author
a.orlenko
committed
IMG.c: Loader now keeps trying other formats, if other supported format(s) failed to load an image
1 parent 001b70e commit 1ff5ac1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/IMG.c

+12
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ SDL_Surface *IMG_LoadTyped_IO(SDL_IOStream *src, bool closeio, const char *type)
189189
SDL_Log("IMGLIB: Loading image as %s\n", supported[i].type);
190190
#endif
191191
image = supported[i].load(src);
192+
if (!image) {
193+
#ifdef DEBUG_IMGLIB
194+
SDL_Log("IMGLIB: Failed to load image as %s. Reason: %s\n", supported[i].type, SDL_GetError());
195+
#endif
196+
continue;
197+
}
192198
if (closeio) {
193199
SDL_CloseIO(src);
194200
}
@@ -291,6 +297,12 @@ IMG_Animation *IMG_LoadAnimationTyped_IO(SDL_IOStream *src, bool closeio, const
291297
SDL_Log("IMGLIB: Loading image as %s\n", supported_anims[i].type);
292298
#endif
293299
anim = supported_anims[i].load(src);
300+
if (!anim) {
301+
#ifdef DEBUG_IMGLIB
302+
SDL_Log("IMGLIB: Failed to load animation as %s. Reason: %s\n", supported[i].type, SDL_GetError());
303+
#endif
304+
continue;
305+
}
294306
if (closeio)
295307
SDL_CloseIO(src);
296308
return anim;

0 commit comments

Comments
 (0)