Playlist editor: fix freeze if mpd playlist_directory doesn't exist

This commit is contained in:
Dmitriy Kusterskiy
2016-09-23 00:25:06 +03:00
committed by Andrzej Rybczak
parent 63cd4473ce
commit d0185af4c1
2 changed files with 16 additions and 5 deletions

1
NEWS
View File

@@ -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.

View File

@@ -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(),