From 705299fcb8e4598ede1accc99563c4d43fe8ce30 Mon Sep 17 00:00:00 2001 From: "J?rgen P. Tjern?" Date: Mon, 25 Feb 2013 16:52:50 -0800 Subject: [PATCH] sdl2 - fix ref counting on init, make sure you refcount each init calls and not just the first one --- src/SDL.c | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/SDL.c b/src/SDL.c index 6011612a9..53e0e7449 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -105,10 +105,12 @@ SDL_InitSubSystem(Uint32 flags) #endif /* Initialize the timer subsystem */ - if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_TIMER)) { + if ((flags & SDL_INIT_TIMER) ){ + if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_TIMER)) { #if !SDL_TIMERS_DISABLED - if (SDL_TimerInit() < 0) { - return (-1); + if (SDL_TimerInit() < 0) { + return (-1); + } } SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER); #else @@ -118,10 +120,12 @@ SDL_InitSubSystem(Uint32 flags) } /* Initialize the video/event subsystem */ - if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_VIDEO)) { + if ((flags & SDL_INIT_VIDEO) ){ + if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_VIDEO)) { #if !SDL_VIDEO_DISABLED - if (SDL_VideoInit(NULL) < 0) { - return (-1); + if (SDL_VideoInit(NULL) < 0) { + return (-1); + } } SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO); #else @@ -131,10 +135,12 @@ SDL_InitSubSystem(Uint32 flags) } /* Initialize the audio subsystem */ - if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_AUDIO)) { + if ((flags & SDL_INIT_AUDIO) ){ + if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_AUDIO)) { #if !SDL_AUDIO_DISABLED - if (SDL_AudioInit(NULL) < 0) { - return (-1); + if (SDL_AudioInit(NULL) < 0) { + return (-1); + } } SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO); #else @@ -149,10 +155,12 @@ SDL_InitSubSystem(Uint32 flags) } /* Initialize the joystick subsystem */ - if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_JOYSTICK)) { + if ((flags & SDL_INIT_JOYSTICK) ){ + if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_JOYSTICK)) { #if !SDL_JOYSTICK_DISABLED - if (SDL_JoystickInit() < 0) { - return (-1); + if (SDL_JoystickInit() < 0) { + return (-1); + } } SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK); #else @@ -161,10 +169,12 @@ SDL_InitSubSystem(Uint32 flags) #endif } - if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_GAMECONTROLLER)) { + if ((flags & SDL_INIT_GAMECONTROLLER) ){ + if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_GAMECONTROLLER)) { #if !SDL_JOYSTICK_DISABLED - if (SDL_GameControllerInit() < 0) { - return (-1); + if (SDL_GameControllerInit() < 0) { + return (-1); + } } SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER); #else @@ -174,10 +184,12 @@ SDL_InitSubSystem(Uint32 flags) } /* Initialize the haptic subsystem */ - if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_HAPTIC)) { + if ((flags & SDL_INIT_HAPTIC) ){ + if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_HAPTIC)) { #if !SDL_HAPTIC_DISABLED - if (SDL_HapticInit() < 0) { - return (-1); + if (SDL_HapticInit() < 0) { + return (-1); + } } SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC); #else