Make g_system_menu no longer a global

This commit is contained in:
twinaphex 2015-12-10 23:08:34 +01:00
parent fc6505e408
commit d7fd52b03f
9 changed files with 69 additions and 34 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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];

View File

@ -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

View File

@ -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);