sdl2
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Mon, 25 Feb 2013 16:52:50 -0800
changeset 69245be9b933146a
parent 6923 d3b709232670
child 6925 59fedfb8faaf
sdl2
- fix ref counting on init, make sure you refcount each init calls and not just the first one
src/SDL.c
     1.1 --- a/src/SDL.c	Mon Feb 25 16:52:48 2013 -0800
     1.2 +++ b/src/SDL.c	Mon Feb 25 16:52:50 2013 -0800
     1.3 @@ -105,10 +105,12 @@
     1.4  #endif
     1.5  
     1.6      /* Initialize the timer subsystem */
     1.7 -    if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_TIMER)) {
     1.8 +    if ((flags & SDL_INIT_TIMER) ){
     1.9 +        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_TIMER)) {
    1.10  #if !SDL_TIMERS_DISABLED
    1.11 -        if (SDL_TimerInit() < 0) {
    1.12 -            return (-1);
    1.13 +            if (SDL_TimerInit() < 0) {
    1.14 +                return (-1);
    1.15 +            }
    1.16          }
    1.17          SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
    1.18  #else
    1.19 @@ -118,10 +120,12 @@
    1.20      }
    1.21  
    1.22      /* Initialize the video/event subsystem */
    1.23 -    if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_VIDEO)) {
    1.24 +    if ((flags & SDL_INIT_VIDEO) ){
    1.25 +        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_VIDEO)) {
    1.26  #if !SDL_VIDEO_DISABLED
    1.27 -        if (SDL_VideoInit(NULL) < 0) {
    1.28 -            return (-1);
    1.29 +            if (SDL_VideoInit(NULL) < 0) {
    1.30 +                return (-1);
    1.31 +            }
    1.32          }
    1.33          SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
    1.34  #else
    1.35 @@ -131,10 +135,12 @@
    1.36      }
    1.37  
    1.38      /* Initialize the audio subsystem */
    1.39 -    if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_AUDIO)) {
    1.40 +    if ((flags & SDL_INIT_AUDIO) ){
    1.41 +        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_AUDIO)) {
    1.42  #if !SDL_AUDIO_DISABLED
    1.43 -        if (SDL_AudioInit(NULL) < 0) {
    1.44 -            return (-1);
    1.45 +            if (SDL_AudioInit(NULL) < 0) {
    1.46 +                return (-1);
    1.47 +            }
    1.48          }
    1.49          SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
    1.50  #else
    1.51 @@ -149,10 +155,12 @@
    1.52      }
    1.53  
    1.54      /* Initialize the joystick subsystem */
    1.55 -    if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_JOYSTICK)) {
    1.56 +    if ((flags & SDL_INIT_JOYSTICK) ){
    1.57 +        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_JOYSTICK)) {
    1.58  #if !SDL_JOYSTICK_DISABLED
    1.59 -        if (SDL_JoystickInit() < 0) {
    1.60 -            return (-1);
    1.61 +           if (SDL_JoystickInit() < 0) {
    1.62 +               return (-1);
    1.63 +           }
    1.64          }
    1.65          SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
    1.66  #else
    1.67 @@ -161,10 +169,12 @@
    1.68  #endif
    1.69      }
    1.70  
    1.71 -    if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_GAMECONTROLLER)) {
    1.72 +    if ((flags & SDL_INIT_GAMECONTROLLER) ){
    1.73 +        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_GAMECONTROLLER)) {
    1.74  #if !SDL_JOYSTICK_DISABLED
    1.75 -        if (SDL_GameControllerInit() < 0) {
    1.76 -            return (-1);
    1.77 +            if (SDL_GameControllerInit() < 0) {
    1.78 +                return (-1);
    1.79 +            }
    1.80          }
    1.81          SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
    1.82  #else
    1.83 @@ -174,10 +184,12 @@
    1.84      }
    1.85  
    1.86      /* Initialize the haptic subsystem */
    1.87 -    if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_HAPTIC)) {
    1.88 +    if ((flags & SDL_INIT_HAPTIC) ){
    1.89 +        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_HAPTIC)) {
    1.90  #if !SDL_HAPTIC_DISABLED
    1.91 -        if (SDL_HapticInit() < 0) {
    1.92 -            return (-1);
    1.93 +            if (SDL_HapticInit() < 0) {
    1.94 +             return (-1);
    1.95 +         }
    1.96          }
    1.97          SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
    1.98  #else