From bb70c398119e463e87fa4767590a5f1e40fb6ff0 Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Wed, 2 Oct 2013 13:50:58 +0200 Subject: [PATCH] Ensure SDL_image and SDL_ttf initialize correctly --- src/main.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c377d37..b553e0e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -127,8 +127,21 @@ int main(int, char *argv[]) return 0; } - IMG_Init(IMG_INIT_PNG | IMG_INIT_JPG); - TTF_Init(); + int imgFlags = IMG_INIT_PNG | IMG_INIT_JPG; + if (IMG_Init(imgFlags) != imgFlags) + { + qDebug() << "Error initializing SDL_image:" << SDL_GetError(); + SDL_Quit(); + return 0; + } + + if (TTF_Init() < 0) + { + qDebug() << "Error initializing SDL_ttf:" << SDL_GetError(); + IMG_Quit(); + SDL_Quit(); + return 0; + } SDL_SetHint("SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS", "0");