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

Commit

Permalink
Remove the viewcontroller from the window when he OpenGL context is d…
Browse files Browse the repository at this point in the history
…estroyed
  • Loading branch information
slouken committed Sep 30, 2012
1 parent 5d0bae4 commit 0779f14
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/video/uikit/SDL_uikitopengles.m
Expand Up @@ -132,15 +132,14 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
[view->viewcontroller setView:view];
[view->viewcontroller retain];
}
[uiwindow addSubview: view];

// The view controller needs to be the root in order to control rotation on iOS 6.0
if (uiwindow.rootViewController == nil) {
uiwindow.rootViewController = view->viewcontroller;
} else {
[uiwindow addSubview: view];
}

if ( UIKit_GL_MakeCurrent(_this, window, view) < 0 ) {
if (UIKit_GL_MakeCurrent(_this, window, view) < 0) {
UIKit_GL_DeleteContext(_this, view);
return NULL;
}
Expand All @@ -159,6 +158,10 @@ void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
/* the delegate has retained the view, this will release him */
SDL_uikitopenglview *view = (SDL_uikitopenglview *)context;
if (view->viewcontroller) {
UIWindow *uiwindow = (UIWindow *)view.superview;
if (uiwindow.rootViewController == view->viewcontroller) {
uiwindow.rootViewController = nil;
}
[view->viewcontroller setView:nil];
[view->viewcontroller release];
}
Expand Down

0 comments on commit 0779f14

Please sign in to comment.