diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index e326bec051..80d6fa1ce2 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -1683,8 +1683,7 @@ static int menu_displaylist_parse_horizontal_list(menu_displaylist_info_t *info) strlcpy(lpl_basename, item->path, sizeof(lpl_basename)); path_remove_extension(lpl_basename); - if (menu->playlist) - content_playlist_free(menu->playlist); + menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_FREE, NULL); fill_pathname_join(path_playlist, settings->playlist_directory, item->path, @@ -2916,8 +2915,7 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) char path_playlist[PATH_MAX_LENGTH]; content_playlist_t *playlist = NULL; - if (menu->playlist) - content_playlist_free(menu->playlist); + menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_FREE, NULL); fill_pathname_join(path_playlist, settings->playlist_directory, info->path, diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 5da92bdbfd..b85bbc3c58 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -537,18 +537,12 @@ void menu_free(menu_handle_t *menu) if (!menu) return; - if (menu->playlist) - content_playlist_free(menu->playlist); - menu->playlist = NULL; - + menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_FREE, NULL); menu_shader_free(menu); - menu_input_ctl(MENU_INPUT_CTL_DEINIT, NULL); menu_navigation_ctl(MENU_NAVIGATION_CTL_DEINIT, NULL); menu_driver_free(menu); - menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_DEINIT, NULL); - menu_display_free(); menu_entries_free(); @@ -666,6 +660,13 @@ 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_PLAYLIST_FREE: + if (!menu_driver_data) + return false; + if (menu_driver_data->playlist) + content_playlist_free(menu_driver_data->playlist); + menu_driver_data->playlist = NULL; + break; case RARCH_MENU_CTL_PLAYLIST_GET: { content_playlist_t **playlist = (content_playlist_t**)data; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 8e9afbb7f3..3e6c2adbd9 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -116,6 +116,7 @@ enum rarch_menu_ctl_state RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, RARCH_MENU_CTL_SYSTEM_INFO_DEINIT, RARCH_MENU_CTL_SYSTEM_INFO_GET, + RARCH_MENU_CTL_PLAYLIST_FREE, RARCH_MENU_CTL_PLAYLIST_GET };