project_files/HedgewarsMobile/Classes/InGameMenuViewController.m
changeset 3926 668b71f31e51
parent 3924 2a9ace189288
child 3971 5c82ee165ed5
--- a/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m	Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m	Wed Oct 06 02:31:04 2010 +0200
@@ -49,15 +49,30 @@
     [array release];
 
     // save the sdl window (!= uikit window) for future reference
-    SDL_VideoDevice *_this = SDL_GetVideoDevice();
-    SDL_VideoDisplay *display = &_this->displays[0];
-    sdlwindow = display->windows;
+    SDL_VideoDevice *videoDevice = SDL_GetVideoDevice();
+    if (videoDevice) {
+        SDL_VideoDisplay *display = &videoDevice->displays[0];
+        if (display)
+            sdlwindow = display->windows;
+    }
+    [super viewDidLoad];
+}
 
-    [super viewDidLoad];
+-(void) viewWillAppear:(BOOL)animated {
+    if (sdlwindow == NULL) {
+        SDL_VideoDevice *_this = SDL_GetVideoDevice();
+        if (_this) {
+            SDL_VideoDisplay *display = &_this->displays[0];
+            if (display)
+                sdlwindow = display->windows;
+        }
+    }
+    [super viewWillAppear:animated];
 }
 
 -(void) viewDidUnload {
     self.menuList = nil;
+    sdlwindow = NULL;
     MSG_DIDUNLOAD();
     [super viewDidUnload];
 }