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

Commit

Permalink
Fix up some retain/release issues with UIScreenMode objects.
Browse files Browse the repository at this point in the history
Fixes Bugzilla #1191.

This patch is based on work done by Vittorio Giovara.
  • Loading branch information
icculus committed Oct 15, 2011
1 parent 0b6aade commit 92d5878
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/video/uikit/SDL_uikitvideo.m
Expand Up @@ -212,7 +212,8 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device)
mode.h = h;
mode.refresh_rate = 0;

[uimode retain];
[uimode retain]; // once for the desktop_mode
[uimode retain]; // once for the current_mode
mode.driverdata = uimode;

SDL_zero(display);
Expand Down Expand Up @@ -286,13 +287,14 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device)
UIScreen *uiscreen = (UIScreen *) display->driverdata;
[uiscreen release];
display->driverdata = NULL;
[((UIScreenMode *) display->desktop_mode.driverdata) release];
display->desktop_mode.driverdata = NULL;
[((UIScreenMode *) display->current_mode.driverdata) release];
display->current_mode.driverdata = NULL;
for (j = 0; j < display->num_display_modes; j++) {
SDL_DisplayMode *mode = &display->display_modes[j];
UIScreenMode *uimode = (UIScreenMode *) mode->driverdata;
if (uimode) {
[uimode release];
mode->driverdata = NULL;
}
[((UIScreenMode *) mode->driverdata) release];
mode->driverdata = NULL;
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/video/uikit/SDL_uikitwindow.m
Expand Up @@ -151,8 +151,13 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
if (bestmode) {
UIScreenMode *uimode = (UIScreenMode *) bestmode->driverdata;
[uiscreen setCurrentMode:uimode];
display->desktop_mode = *bestmode;

// desktop_mode doesn't change here (the higher level will
// use it to set all the screens back to their defaults
// upon window destruction, SDL_Quit(), etc.
[((UIScreenMode *) display->current_mode.driverdata) release];
display->current_mode = *bestmode;
[((UIScreenMode *) display->current_mode.driverdata) retain];
}
}
}
Expand Down

0 comments on commit 92d5878

Please sign in to comment.