Skip to content

Commit

Permalink
Sam Lantinga - Sun Nov 8 07:52:11 PST 2009
Browse files Browse the repository at this point in the history
 * Fixed checking for IMG_Init() return value in image loaders
  • Loading branch information
slouken committed Nov 8, 2009
1 parent da99576 commit 694bc6f
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGES
@@ -1,3 +1,7 @@
1.2.9:
Sam Lantinga - Sun Nov 8 07:52:11 PST 2009
* Fixed checking for IMG_Init() return value in image loaders

1.2.8:
Sam Lantinga - Sun Oct 4 13:12:54 PDT 2009
* Added support for uncompressed PCX files
Expand Down
13 changes: 3 additions & 10 deletions IMG.c
Expand Up @@ -61,20 +61,16 @@ const SDL_version *IMG_Linked_Version(void)
}

extern int IMG_InitJPG();
extern int IMG_QuitJPG();
extern void IMG_QuitJPG();
extern int IMG_InitPNG();
extern int IMG_QuitPNG();
extern void IMG_QuitPNG();
extern int IMG_InitTIF();
extern int IMG_QuitTIF();
extern void IMG_QuitTIF();

static int initialized = 0;

int IMG_Init(int flags)
{
#if defined(__APPLE__) && !defined(SDL_IMAGE_USE_COMMON_BACKEND)
initialized = IMG_INIT_JPG | IMG_INIT_PNG | IMG_INIT_TIF;
return initialized;
#else
int result = 0;

if ((flags & IMG_INIT_JPG) && !(initialized & IMG_INIT_JPG)) {
Expand All @@ -95,12 +91,10 @@ int IMG_Init(int flags)
initialized |= result;

return (result);
#endif
}

void IMG_Quit()
{
#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
if (initialized & IMG_INIT_JPG) {
IMG_QuitJPG();
}
Expand All @@ -110,7 +104,6 @@ void IMG_Quit()
if (initialized & IMG_INIT_TIF) {
IMG_QuitTIF();
}
#endif
initialized = 0;
}

Expand Down
26 changes: 26 additions & 0 deletions IMG_ImageIO.c
Expand Up @@ -449,6 +449,32 @@ static SDL_Surface* LoadImageFromFile(const char* file)
return sdl_surface;
}

int IMG_InitJPG()
{
return 0;
}

void IMG_QuitJPG()
{
}

int IMG_InitPNG()
{
return 0;
}

void IMG_QuitPNG()
{
}

int IMG_InitTIF()
{
return 0;
}

void IMG_QuitTIF()
{
}

int IMG_isCUR(SDL_RWops *src)
{
Expand Down
26 changes: 26 additions & 0 deletions IMG_UIImage.m
Expand Up @@ -265,6 +265,32 @@
}


int IMG_InitJPG()
{
return 0;
}

void IMG_QuitJPG()
{
}

int IMG_InitPNG()
{
return 0;
}

void IMG_QuitPNG()
{
}

int IMG_InitTIF()
{
return 0;
}

void IMG_QuitTIF()
{
}

/* Copied straight from other files so I don't have to alter them. */
static int IMG_isICOCUR(SDL_RWops *src, int type)
Expand Down
2 changes: 1 addition & 1 deletion IMG_jpg.c
Expand Up @@ -379,7 +379,7 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)
}
start = SDL_RWtell(src);

if ( IMG_Init(IMG_INIT_JPG) < 0 ) {
if ( !IMG_Init(IMG_INIT_JPG) ) {
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion IMG_png.c
Expand Up @@ -318,7 +318,7 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src)
}
start = SDL_RWtell(src);

if ( IMG_Init(IMG_INIT_PNG) < 0 ) {
if ( !IMG_Init(IMG_INIT_PNG) ) {
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion IMG_tif.c
Expand Up @@ -216,7 +216,7 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)
}
start = SDL_RWtell(src);

if ( IMG_Init(IMG_INIT_TIF) < 0 ) {
if ( !IMG_Init(IMG_INIT_TIF) ) {
return NULL;
}

Expand Down
4 changes: 3 additions & 1 deletion SDL_image.h
Expand Up @@ -64,7 +64,9 @@ typedef enum
} IMG_InitFlags;

/* Loads dynamic libraries and prepares them for use. Flags should be
one or more flags from IMG_InitFlags OR'd together */
one or more flags from IMG_InitFlags OR'd together.
It returns the flags successfully initialized, or 0 on failure.
*/
extern DECLSPEC int SDLCALL IMG_Init(int flags);

/* Unloads libraries loaded with IMG_Init */
Expand Down

0 comments on commit 694bc6f

Please sign in to comment.