Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
sdl2
Browse files Browse the repository at this point in the history
- fix ref counting on init, make sure you refcount each init calls and not just the first one
  • Loading branch information
jorgenpt committed Feb 26, 2013
1 parent 8ee7017 commit 705299f
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions src/SDL.c
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 705299f

Please sign in to comment.