diff --git a/apple/common/RAGameView.m b/apple/common/RAGameView.m index d493d43b40..9e6da80264 100644 --- a/apple/common/RAGameView.m +++ b/apple/common/RAGameView.m @@ -238,18 +238,19 @@ static bool g_is_syncing = true; static RAScreen* get_chosen_screen() { - unsigned monitor = g_settings.video.monitor_index; - - @autoreleasepool + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + if (g_settings.video.monitor_index >= RAScreen.screens.count) { - if (monitor >= RAScreen.screens.count) - { - RARCH_WARN("video_monitor_index is greater than the number of connected monitors; using main screen instead.\n"); - return RAScreen.mainScreen; - } - - return RAScreen.screens[monitor]; + RARCH_WARN("video_monitor_index is greater than the number of connected monitors; using main screen instead.\n"); + [pool drain]; + return RAScreen.mainScreen; } + + NSArray *screens = [RAScreen screens]; + RAScreen *s = (RAScreen*)[screens objectAtIndex:g_settings.video.monitor_index]; + [pool drain]; + return s; } bool apple_gfx_ctx_init()