diff --git a/NEWS b/NEWS index 9c9f6951..ce8a545f 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ ncmpcpp-0.7.6 (????-??-??) * Fixed assertion failure on trying to search backwards in an empty list. * Updated installation instructions in INSTALL file. * Make sure that stream of random numbers is not deterministic. +* Opening playlist editor when there is no MPD playlists directory no longer freezes the application. ncmpcpp-0.7.5 (2016-08-17) * Action chains can be now used for seeking. diff --git a/src/playlist_editor.cpp b/src/playlist_editor.cpp index 2dd7eb75..0c25b520 100644 --- a/src/playlist_editor.cpp +++ b/src/playlist_editor.cpp @@ -147,13 +147,23 @@ void PlaylistEditor::update() { m_playlists_update_requested = false; size_t idx = 0; - for (MPD::PlaylistIterator it = Mpd.GetPlaylists(), end; it != end; ++it, ++idx) + try { - if (idx < Playlists.size()) - Playlists[idx].value() = std::move(*it); + for (MPD::PlaylistIterator it = Mpd.GetPlaylists(), end; it != end; ++it, ++idx) + { + if (idx < Playlists.size()) + Playlists[idx].value() = std::move(*it); + else + Playlists.addItem(std::move(*it)); + }; + } + catch (MPD::ServerError &e) + { + if (e.code() == MPD_SERVER_ERROR_SYSTEM) // no playlists directory + Statusbar::print(e.what()); else - Playlists.addItem(std::move(*it)); - }; + throw; + } if (idx < Playlists.size()) Playlists.resizeList(idx); std::sort(Playlists.beginV(), Playlists.endV(),