From a5e6c3273cd894ad336b194d4c47f78add32b835 Mon Sep 17 00:00:00 2001 From: Arnaud Bienner Date: Sat, 29 Jun 2013 16:16:52 +0200 Subject: [PATCH] Delete a playlist when unstaring it from the left 'Playlists' panel and when it's not opened --- src/playlist/playlistmanager.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index 89bf66af5..684ef1cba 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -254,10 +254,18 @@ void PlaylistManager::Rename(int id, const QString& new_name) { } void PlaylistManager::Favorite(int id, bool favorite) { - Q_ASSERT(playlists_.contains(id)); - playlist_backend_->FavoritePlaylist(id, favorite); - playlists_[id].p->set_favorite(favorite); + if (playlists_.contains(id)) { + // If playlists_ contains this playlist, its means it's opened: star or unstar it. + playlist_backend_->FavoritePlaylist(id, favorite); + playlists_[id].p->set_favorite(favorite); + } else { + Q_ASSERT(!favorite); + // Otherwise it means user wants to remove this playlist from the left panel, + // while it's not visible in the playlist tabbar either, because it has been + // closed: delete it. + playlist_backend_->RemovePlaylist(id); + } emit PlaylistFavorited(id, favorite); }