Recover from invalid directory in Browser::locateSong
This commit is contained in:
@@ -427,18 +427,29 @@ void Browser::locateSong(const MPD::Song &s)
|
|||||||
|
|
||||||
w.clearFilter();
|
w.clearFilter();
|
||||||
|
|
||||||
// change to relevant directory
|
try
|
||||||
if (m_current_directory != s.getDirectory())
|
|
||||||
{
|
{
|
||||||
getDirectory(s.getDirectory());
|
// Try to change to relevant directory.
|
||||||
drawHeader();
|
if (m_current_directory != s.getDirectory())
|
||||||
}
|
{
|
||||||
|
getDirectory(s.getDirectory());
|
||||||
|
drawHeader();
|
||||||
|
}
|
||||||
|
|
||||||
// highlight the item
|
// Highlight the item.
|
||||||
auto begin = w.beginV(), end = w.endV();
|
auto begin = w.beginV(), end = w.endV();
|
||||||
auto it = std::find(begin, end, MPD::Item(s));
|
auto it = std::find(begin, end, MPD::Item(s));
|
||||||
if (it != end)
|
if (it != end)
|
||||||
w.highlight(it-begin);
|
w.highlight(it-begin);
|
||||||
|
}
|
||||||
|
catch (MPD::ServerError &err)
|
||||||
|
{
|
||||||
|
// If the directory is invalid, recover by invoking the update.
|
||||||
|
if (err.code() == MPD_SERVER_ERROR_NO_EXIST)
|
||||||
|
requestUpdate();
|
||||||
|
else
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Browser::enterDirectory()
|
bool Browser::enterDirectory()
|
||||||
|
|||||||
Reference in New Issue
Block a user