diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 81aa533697..5665516744 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -461,6 +461,7 @@ static int file_load_with_detect_core_wrapper(size_t idx, size_t entry_idx, { menu_content_ctx_defer_info_t def_info; content_ctx_info_t content_info = {0}; + char new_core_path[PATH_MAX_LENGTH] = {0}; char menu_path_new[PATH_MAX_LENGTH] = {0}; int ret = 0; const char *menu_path = NULL; @@ -494,7 +495,8 @@ static int file_load_with_detect_core_wrapper(size_t idx, size_t entry_idx, def_info.s = menu->deferred_path; def_info.len = sizeof(menu->deferred_path); - if (menu_content_find_first_core(&def_info, false)) + if (menu_content_find_first_core(&def_info, false, new_core_path, + sizeof(new_core_path))) ret = -1; if ( !is_carchive && !string_is_empty(path) @@ -509,9 +511,7 @@ static int file_load_with_detect_core_wrapper(size_t idx, size_t entry_idx, switch (ret) { case -1: - command_event(CMD_EVENT_LOAD_CORE, NULL); - - task_push_content_load_default(NULL, NULL, + task_push_content_load_default(new_core_path, NULL, &content_info, CORE_TYPE_PLAIN, CONTENT_MODE_LOAD_CONTENT_WITH_NEW_CORE_FROM_MENU, NULL, NULL); @@ -2333,12 +2333,13 @@ static int action_ok_load_archive_detect_core(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { menu_content_ctx_defer_info_t def_info; - content_ctx_info_t content_info = {0}; - int ret = 0; - core_info_list_t *list = NULL; - menu_handle_t *menu = NULL; - const char *menu_path = NULL; - const char *content_path = NULL; + content_ctx_info_t content_info = {0}; + char new_core_path[PATH_MAX_LENGTH] = {0}; + int ret = 0; + core_info_list_t *list = NULL; + menu_handle_t *menu = NULL; + const char *menu_path = NULL; + const char *content_path = NULL; if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return menu_cbs_exit(); @@ -2358,7 +2359,7 @@ static int action_ok_load_archive_detect_core(const char *path, def_info.s = menu->deferred_path; def_info.len = sizeof(menu->deferred_path); - if (menu_content_find_first_core(&def_info, false)) + if (menu_content_find_first_core(&def_info, false, new_core_path, sizeof(new_core_path))) ret = -1; fill_pathname_join(detect_content_path, menu_path, content_path, @@ -2367,11 +2368,10 @@ static int action_ok_load_archive_detect_core(const char *path, switch (ret) { case -1: - command_event(CMD_EVENT_LOAD_CORE, NULL); - task_push_content_load_default(NULL, NULL, + task_push_content_load_default(new_core_path, NULL, &content_info, CORE_TYPE_PLAIN, - CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_MENU, + CONTENT_MODE_LOAD_CONTENT_WITH_NEW_CORE_FROM_MENU, NULL, NULL); return 0; case 0: diff --git a/menu/menu_content.c b/menu/menu_content.c index 2a04a9bb83..4f0d18a5d8 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -125,9 +125,9 @@ error: * selection needs to be made from a list, otherwise * returns true and fills in @s with path to core. **/ -bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info, bool load_content_with_current_core) +bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info, bool load_content_with_current_core, + char *new_core_path, size_t len) { - char new_core_path[PATH_MAX_LENGTH] = {0}; const core_info_t *info = NULL; core_info_list_t *core_info = NULL; const char *default_info_dir = NULL; @@ -185,13 +185,10 @@ bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info, bool return false; if (info) - strlcpy(new_core_path, info->path, sizeof(new_core_path)); + strlcpy(new_core_path, info->path, len); runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, def_info->s); - if (path_file_exists(new_core_path)) - runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, new_core_path); - return true; } diff --git a/menu/menu_content.h b/menu/menu_content.h index 69aaac1706..2123d444ce 100644 --- a/menu/menu_content.h +++ b/menu/menu_content.h @@ -60,7 +60,8 @@ typedef struct menu_content_ctx_defer_info size_t len; } menu_content_ctx_defer_info_t; -bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info, bool load_content_with_current_core); +bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info, bool load_content_with_current_core, + char *new_core_path, size_t len); bool menu_content_ctl(enum menu_content_ctl_state state, void *data);