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

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