diff --git a/src/actions.cpp b/src/actions.cpp index 649aebfe..17c51539 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -724,12 +724,13 @@ void DeleteBrowserItems::run() bool DeleteStoredPlaylist::canBeRun() const { - return myScreen->isActiveWindow(myPlaylistEditor->Playlists) - && myPlaylistEditor->Playlists.empty(); + return myScreen->isActiveWindow(myPlaylistEditor->Playlists); } void DeleteStoredPlaylist::run() { + if (myPlaylistEditor->Playlists.empty()) + return; boost::format question; if (hasSelected(myPlaylistEditor->Playlists.begin(), myPlaylistEditor->Playlists.end())) question = boost::format("Delete selected playlists?"); @@ -740,10 +741,8 @@ void DeleteStoredPlaylist::run() if (yes) { auto list = getSelectedOrCurrent(myPlaylistEditor->Playlists.begin(), myPlaylistEditor->Playlists.end(), myPlaylistEditor->Playlists.currentI()); - Mpd.StartCommandsList(); for (auto it = list.begin(); it != list.end(); ++it) Mpd.DeletePlaylist((*it)->value()); - Mpd.CommitCommandsList(); Statusbar::printf("%1% deleted", list.size() == 1 ? "Playlist" : "Playlists"); } else diff --git a/src/playlist_editor.cpp b/src/playlist_editor.cpp index 73621ded..dcc118f0 100644 --- a/src/playlist_editor.cpp +++ b/src/playlist_editor.cpp @@ -156,41 +156,45 @@ void PlaylistEditor::update() Playlists.refresh(); } - if (!Playlists.empty() - && ((Content.reallyEmpty() && Global::Timer - m_timer > m_fetching_delay) || m_content_update_requested) - ) + if ((Content.reallyEmpty() && Global::Timer - m_timer > m_fetching_delay) + || m_content_update_requested) { m_content_update_requested = false; - Content.clearSearchResults(); - withUnfilteredMenuReapplyFilter(Content, [this]() { - size_t idx = 0; - Mpd.GetPlaylistContent(Playlists.current().value(), [this, &idx](MPD::Song s) { + if (Playlists.empty()) + Content.clear(); + else + { + Content.clearSearchResults(); + withUnfilteredMenuReapplyFilter(Content, [this]() { + size_t idx = 0; + Mpd.GetPlaylistContent(Playlists.current().value(), [this, &idx](MPD::Song s) { + if (idx < Content.size()) + { + Content[idx].value() = s; + Content[idx].setBold(myPlaylist->checkForSong(s)); + } + else + Content.addItem(s, myPlaylist->checkForSong(s)); + ++idx; + }); if (idx < Content.size()) + Content.resizeList(idx); + std::string title; + if (Config.titles_visibility) { - Content[idx].value() = s; - Content[idx].setBold(myPlaylist->checkForSong(s)); + title = "Playlist content"; + title += " ("; + title += boost::lexical_cast(Content.size()); + title += " item"; + if (Content.size() == 1) + title += ")"; + else + title += "s)"; + title.resize(Content.getWidth()); } - else - Content.addItem(s, myPlaylist->checkForSong(s)); - ++idx; + Content.setTitle(title); }); - if (idx < Content.size()) - Content.resizeList(idx); - std::string title; - if (Config.titles_visibility) - { - title = "Playlist content"; - title += " ("; - title += boost::lexical_cast(Content.size()); - title += " item"; - if (Content.size() == 1) - title += ")"; - else - title += "s)"; - title.resize(Content.getWidth()); - } - Content.setTitle(title); - }); + } Content.display(); }