Use a small function to release UIScreenMode after checking it is supported
authorKees Bakker
Tue, 18 Oct 2011 21:36:28 +0200
changeset 60193d8b1ada8ad5
parent 6018 fa4a3c1d857b
child 6020 5374ddd99862
Use a small function to release UIScreenMode after checking it is supported
src/video/uikit/SDL_uikitvideo.m
     1.1 --- a/src/video/uikit/SDL_uikitvideo.m	Tue Oct 18 21:32:54 2011 +0200
     1.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Tue Oct 18 21:36:28 2011 +0200
     1.3 @@ -242,6 +242,19 @@
     1.4      return 0;
     1.5  }
     1.6  
     1.7 +static void
     1.8 +UIKit_ReleaseUIScreenMode(SDL_DisplayMode * mode)
     1.9 +{
    1.10 +    if (!SDL_UIKit_supports_multiple_displays) {
    1.11 +        // Not on at least iPhoneOS 3.2 (versions prior to iPad).
    1.12 +        SDL_assert(mode->driverdata == NULL);
    1.13 +    } else {
    1.14 +        UIScreenMode *uimode = (UIScreenMode *) mode->driverdata;
    1.15 +        [uimode release];
    1.16 +        mode->driverdata = NULL;
    1.17 +    }
    1.18 +}
    1.19 +
    1.20  void
    1.21  UIKit_VideoQuit(_THIS)
    1.22  {
    1.23 @@ -252,14 +265,11 @@
    1.24          UIScreen *uiscreen = (UIScreen *) display->driverdata;
    1.25          [uiscreen release];
    1.26          display->driverdata = NULL;
    1.27 -        [((UIScreenMode *) display->desktop_mode.driverdata) release];
    1.28 -        display->desktop_mode.driverdata = NULL;
    1.29 -        [((UIScreenMode *) display->current_mode.driverdata) release];
    1.30 -        display->current_mode.driverdata = NULL;
    1.31 +        UIKit_ReleaseUIScreenMode(&display->desktop_mode);
    1.32 +        UIKit_ReleaseUIScreenMode(&display->current_mode);
    1.33          for (j = 0; j < display->num_display_modes; j++) {
    1.34              SDL_DisplayMode *mode = &display->display_modes[j];
    1.35 -            [((UIScreenMode *) mode->driverdata) release];
    1.36 -            mode->driverdata = NULL;
    1.37 +            UIKit_ReleaseUIScreenMode(mode);
    1.38          }
    1.39      }
    1.40  }