Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix up some retain/release issues with UIScreenMode objects.

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 92d58787483c6a0f114871d1cac51b6632b3d6b4
Showing with 14 additions and 7 deletions.
  1. +8 −6 src/video/uikit/SDL_uikitvideo.m
  2. +6 −1 src/video/uikit/SDL_uikitwindow.m
@@ -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);
@@ -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;
}
}
}
@@ -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];
}
}
}

0 comments on commit 92d5878

Please sign in to comment.