Remove the viewcontroller from the window when he OpenGL context is destroyed
authorSam Lantinga
Sun, 30 Sep 2012 01:01:48 -0700
changeset 6521f36bbe0a10c9
parent 6520 7a7726af31c1
child 6522 edacce9402fb
Remove the viewcontroller from the window when he OpenGL context is destroyed
src/video/uikit/SDL_uikitopengles.m
     1.1 --- a/src/video/uikit/SDL_uikitopengles.m	Sat Sep 29 18:52:00 2012 -0700
     1.2 +++ b/src/video/uikit/SDL_uikitopengles.m	Sun Sep 30 01:01:48 2012 -0700
     1.3 @@ -132,15 +132,14 @@
     1.4          [view->viewcontroller setView:view];
     1.5          [view->viewcontroller retain];
     1.6      }
     1.7 +    [uiwindow addSubview: view];
     1.8      
     1.9      // The view controller needs to be the root in order to control rotation on iOS 6.0
    1.10      if (uiwindow.rootViewController == nil) {
    1.11          uiwindow.rootViewController = view->viewcontroller;
    1.12 -    } else {
    1.13 -        [uiwindow addSubview: view];
    1.14      }
    1.15  
    1.16 -    if ( UIKit_GL_MakeCurrent(_this, window, view) < 0 ) {
    1.17 +    if (UIKit_GL_MakeCurrent(_this, window, view) < 0) {
    1.18          UIKit_GL_DeleteContext(_this, view);
    1.19          return NULL;
    1.20      }
    1.21 @@ -159,6 +158,10 @@
    1.22      /* the delegate has retained the view, this will release him */
    1.23      SDL_uikitopenglview *view = (SDL_uikitopenglview *)context;
    1.24      if (view->viewcontroller) {
    1.25 +        UIWindow *uiwindow = (UIWindow *)view.superview;
    1.26 +        if (uiwindow.rootViewController == view->viewcontroller) {
    1.27 +            uiwindow.rootViewController = nil;
    1.28 +        }
    1.29          [view->viewcontroller setView:nil];
    1.30          [view->viewcontroller release];
    1.31      }