diff --git a/command_event.c b/command_event.c index 9154bb1fb0..44e4484dad 100644 --- a/command_event.c +++ b/command_event.c @@ -942,10 +942,8 @@ bool event_command(enum event_command cmd) } break; case EVENT_CMD_LOAD_CORE_DEINIT: -#ifdef HAVE_DYNAMIC #ifdef HAVE_MENU - libretro_free_system_info(&g_system_menu); -#endif + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_DEINIT, NULL); #endif break; case EVENT_CMD_LOAD_CORE_PERSIST: @@ -953,8 +951,12 @@ bool event_command(enum event_command cmd) { #ifdef HAVE_MENU bool *ptr = NULL; + struct retro_system_info *system = NULL; + + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system); + if (menu_driver_ctl(RARCH_MENU_CTL_LOAD_NO_CONTENT_GET, &ptr)) - event_update_system_info(&g_system_menu, ptr); + event_update_system_info(system, ptr); #endif } break; diff --git a/driver.c b/driver.c index 9295adabd1..83882d3147 100644 --- a/driver.c +++ b/driver.c @@ -331,7 +331,10 @@ bool driver_update_system_av_info(const void *data) **/ static void menu_update_libretro_info(void) { - struct retro_system_info *info = &g_system_menu; + struct retro_system_info *info = NULL; + + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, + &info); if (!info) return; diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index e5469f90ad..42b5c35881 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -509,11 +509,13 @@ enum static int general_push(menu_displaylist_info_t *info, unsigned id, unsigned type) { + struct retro_system_info *system_menu = NULL; settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; menu_handle_t *menu = menu_driver_get_ptr(); const char *exts = core_info_list_get_all_extensions(); + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system_menu); runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); switch (id) @@ -538,10 +540,10 @@ static int general_push(menu_displaylist_info_t *info, unsigned id, unsigned typ if (exts) strlcpy(info->exts, exts, sizeof(info->exts)); - else if (g_system_menu.valid_extensions) + else if (system_menu->valid_extensions) { - if (*g_system_menu.valid_extensions) - strlcpy(info->exts, g_system_menu.valid_extensions, + if (*system_menu->valid_extensions) + strlcpy(info->exts, system_menu->valid_extensions, sizeof(info->exts)); } else @@ -549,10 +551,10 @@ static int general_push(menu_displaylist_info_t *info, unsigned id, unsigned typ break; case PUSH_ARCHIVE_OPEN: info->setting = menu_setting_find(info->label); - if (g_system_menu.valid_extensions) + if (system_menu->valid_extensions) { - if (*g_system_menu.valid_extensions) - strlcpy(info->exts, g_system_menu.valid_extensions, + if (*system_menu->valid_extensions) + strlcpy(info->exts, system_menu->valid_extensions, sizeof(info->exts)); } else @@ -563,10 +565,10 @@ static int general_push(menu_displaylist_info_t *info, unsigned id, unsigned typ if (menu_setting_get_browser_selection_type(info->setting) == ST_DIR) { } - else if (g_system_menu.valid_extensions) + else if (system_menu->valid_extensions) { - if (*g_system_menu.valid_extensions) - strlcpy(info->exts, g_system_menu.valid_extensions, + if (*system_menu->valid_extensions) + strlcpy(info->exts, system_menu->valid_extensions, sizeof(info->exts)); } else diff --git a/menu/menu_driver.c b/menu/menu_driver.c index bd6fafc124..2ea5b40c3f 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -412,8 +412,9 @@ static void menu_environment_get(int *argc, char *argv[], static void menu_push_to_history_playlist(void) { - settings_t *settings = config_get_ptr(); - char *fullpath = NULL; + struct retro_system_info *system = NULL; + settings_t *settings = config_get_ptr(); + char *fullpath = NULL; if (!settings->history_list_enable) return; @@ -430,11 +431,14 @@ static void menu_push_to_history_playlist(void) menu_display_msg_queue_push(str, 1, 1, false); } + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, + &system); + content_playlist_push(g_defaults.history, fullpath, NULL, settings->libretro, - g_system_menu.library_name, + system->library_name, NULL, NULL); } @@ -543,9 +547,7 @@ void menu_free(menu_handle_t *menu) menu_navigation_free(); menu_driver_free(menu); -#ifdef HAVE_DYNAMIC - libretro_free_system_info(&g_system_menu); -#endif + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_DEINIT, NULL); menu_display_free(); menu_entries_free(); @@ -648,6 +650,7 @@ error: bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) { + static struct retro_system_info menu_driver_system; static bool menu_driver_prevent_populate = false; static bool menu_driver_load_no_content = false; static bool menu_driver_alive = false; @@ -663,6 +666,19 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) menu_driver_data_own = false; menu_driver_ctx = NULL; break; + case RARCH_MENU_CTL_SYSTEM_INFO_GET: + { + struct retro_system_info **system = (struct retro_system_info**)data; + if (!system) + return false; + *system = &menu_driver_system; + } + return true; + case RARCH_MENU_CTL_SYSTEM_INFO_DEINIT: +#ifdef HAVE_DYNAMIC + libretro_free_system_info(&menu_driver_system); +#endif + break; case RARCH_MENU_CTL_RENDER: menu_iterate_render(menu_driver_data, menu_driver_data ? menu_driver_data->userdata : NULL); diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 9bb6880742..ba1fe4eec1 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -115,7 +115,9 @@ enum rarch_menu_ctl_state RARCH_MENU_CTL_LOAD_NO_CONTENT_GET, RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, RARCH_MENU_CTL_SET_LOAD_NO_CONTENT, - RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT + RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, + RARCH_MENU_CTL_SYSTEM_INFO_DEINIT, + RARCH_MENU_CTL_SYSTEM_INFO_GET }; typedef enum diff --git a/menu/menu_entries.c b/menu/menu_entries.c index edf52f7bad..67a610dd65 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -458,10 +458,17 @@ bool menu_entries_show_back(void) * (shown at the top of the UI). */ int menu_entries_get_core_title(char *s, size_t len) { + struct retro_system_info *system = NULL; rarch_system_info_t *info = NULL; settings_t *settings = config_get_ptr(); - const char *core_name = g_system_menu.library_name; - const char *core_version = g_system_menu.library_version; + const char *core_name = NULL; + const char *core_version = NULL; + + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, + &system); + + core_name = system->library_name; + core_version = system->library_version; runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); diff --git a/runloop.c b/runloop.c index 12ee08b5c7..a8a8f5a83d 100644 --- a/runloop.c +++ b/runloop.c @@ -70,11 +70,6 @@ #define DEFAULT_EXT "" #endif - -#ifdef HAVE_MENU -struct retro_system_info g_system_menu; -#endif - typedef struct event_cmd_state { retro_input_t state[3]; diff --git a/system.h b/system.h index bde4dda5e1..3611758305 100644 --- a/system.h +++ b/system.h @@ -63,10 +63,6 @@ typedef struct rarch_system_info unsigned num_ports; } rarch_system_info_t; -#ifdef HAVE_MENU -extern struct retro_system_info g_system_menu; -#endif - #ifdef __cplusplus } #endif diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index b2e52b618a..dad5366fbc 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -273,8 +273,14 @@ extern void action_ok_push_quick_menu(void); { if (filenames.count == 1 && [filenames objectAtIndex:0]) { + struct retro_system_info *system = NULL; NSString *__core = [filenames objectAtIndex:0]; - const char *core_name = g_system_menu.library_name; + const char *core_name = NULL; + + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system); + + if (system) + core_name = system->library_name; runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)__core.UTF8String); @@ -335,9 +341,15 @@ extern void action_ok_push_quick_menu(void); if (result == NSOKButton && panel.URL) { + struct retro_system_info *system = NULL; NSURL *url = (NSURL*)panel.URL; NSString *__core = url.path; - const char *core_name = g_system_menu.library_name; + const char *core_name = NULL; + + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system); + + if (system) + core_name = system->library_name; runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)__core.UTF8String);