diff --git a/menu/menu_explore.c b/menu/menu_explore.c index 61fe77ea4e..3400bb549d 100644 --- a/menu/menu_explore.c +++ b/menu/menu_explore.c @@ -486,8 +486,7 @@ static void explore_free(explore_state_t *state) EX_BUF_FREE(state->entries); for (i = 0; i != EX_BUF_LEN(state->playlists); i++) - if (state->playlists[i] != state->cached_playlist) - playlist_free(state->playlists[i]); + playlist_free(state->playlists[i]); EX_BUF_FREE(state->playlists); ex_arena_free(&state->arena); } @@ -968,16 +967,6 @@ unsigned menu_displaylist_explore(file_list_t *list) " '%s'", explore_state->find_string); } - if (current_type == MENU_EXPLORE_TAB) - { - /* free any existing playlist - * when entering the explore view */ - playlist_free_cached(); - } - - playlist_set_cached(NULL); - explore_state->cached_playlist = NULL; - if ( current_type == MENU_EXPLORE_TAB || current_type == EXPLORE_TYPE_ADDITIONALFILTER) { @@ -1218,8 +1207,7 @@ SKIP_ENTRY:; /* Fake all the state so the content screen * and information screen think we're viewing via playlist */ - playlist_set_cached(pl); - explore_state->cached_playlist = pl; + playlist_set_cached_external(pl); menu->rpl_entry_selection_ptr = (pl_entry - pl_first); strlcpy(menu->deferred_path, pl_entry->path, sizeof(menu->deferred_path)); diff --git a/playlist.c b/playlist.c index f6a720af52..029e0a1d56 100644 --- a/playlist.c +++ b/playlist.c @@ -56,6 +56,7 @@ struct content_playlist bool modified; bool old_format; bool compressed; + bool cached_external; enum playlist_label_display_mode label_display_mode; enum playlist_thumbnail_mode right_thumbnail_mode; @@ -107,9 +108,11 @@ typedef int (playlist_sort_fun_t)( /* TODO/FIXME - hack for allowing the explore view to switch * over to a playlist item */ -void playlist_set_cached(playlist_t* pl) +void playlist_set_cached_external(playlist_t* pl) { + playlist_free_cached(); playlist_cached = pl; + playlist_cached->cached_external = true; } /* Convenience function: copies specified playlist @@ -1386,9 +1389,10 @@ void playlist_write_runtime_file(playlist_t *playlist) JSON_Writer_WriteNewLine(context.writer); JSON_Writer_Free(context.writer); - playlist->modified = false; - playlist->old_format = false; - playlist->compressed = false; + playlist->modified = false; + playlist->old_format = false; + playlist->compressed = false; + playlist->cached_external = false; RARCH_LOG("[Playlist]: Written to playlist file: %s\n", playlist->config.path); end: @@ -2609,7 +2613,8 @@ end: void playlist_free_cached(void) { - playlist_free(playlist_cached); + if (playlist_cached && !playlist_cached->cached_external) + playlist_free(playlist_cached); playlist_cached = NULL; } @@ -2668,6 +2673,7 @@ playlist_t *playlist_init(const playlist_config_t *config) playlist->modified = false; playlist->old_format = false; playlist->compressed = false; + playlist->cached_external = false; playlist->size = 0; playlist->default_core_name = NULL; playlist->default_core_path = NULL; diff --git a/playlist.h b/playlist.h index 0271f4e634..d68692666b 100644 --- a/playlist.h +++ b/playlist.h @@ -351,7 +351,7 @@ core_info_t *playlist_entry_get_core_info(const struct playlist_entry* entry); * default core association */ core_info_t *playlist_get_default_core_info(playlist_t* playlist); -void playlist_set_cached(playlist_t* pl); +void playlist_set_cached_external(playlist_t* pl); RETRO_END_DECLS