(iOS Thread) Fix crash when returning from background

This commit is contained in:
meancoot 2013-04-03 11:48:24 -04:00
parent c778844852
commit 67ced23555
3 changed files with 19 additions and 15 deletions

View File

@ -105,6 +105,18 @@ static UIView* g_pause_indicator_view;
];
}
- (void)suspend
{
g_view.context = nil;
[EAGLContext setCurrentContext:nil];
}
- (void)resume
{
g_view.context = g_context;
[EAGLContext setCurrentContext:g_context];
}
@end
bool ios_init_game_view()
@ -169,7 +181,8 @@ void ios_get_game_view_size(unsigned *width, unsigned *height)
void ios_bind_game_view_fbo()
{
dispatch_sync(dispatch_get_main_queue(), ^{
[g_view bindDrawable];
if (g_context)
[g_view display];
});
}

View File

@ -52,16 +52,6 @@ static void event_set_state_slot(void* userdata)
g_extern.state_slot = (uint32_t)userdata;
}
static void event_init_drivers(void* userdata)
{
init_drivers();
}
static void event_uninit_drivers(void* userdata)
{
uninit_drivers();
}
static void event_reload_config(void* userdata)
{
// Need to clear these otherwise stale versions may be used!
@ -114,14 +104,12 @@ static void event_reload_config(void* userdata)
- (void)applicationWillEnterForeground:(UIApplication *)application
{
if (_isRunning)
ios_frontend_post_event(&event_init_drivers, 0);
[RAGameView.get resume];
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
if (_isRunning)
ios_frontend_post_event(&event_uninit_drivers, 0);
[RAGameView.get suspend];
}
// UINavigationControllerDelegate

View File

@ -22,6 +22,9 @@
+ (RAGameView*)get;
- (void)openPauseMenu;
- (void)closePauseMenu;
- (void)suspend;
- (void)resume;
@end
@interface RALogView : UITableViewController