fix going to wrong directory in tag editor

This commit is contained in:
Andrzej Rybczak
2011-11-09 16:11:14 +01:00
parent ca956c3da3
commit 78cd46b756

View File

@@ -872,7 +872,11 @@ void TagEditor::LocateSong(const MPD::Song &s)
if (itsBrowsedDir != s.GetDirectory()) if (itsBrowsedDir != s.GetDirectory())
{ {
itsBrowsedDir = s.GetDirectory(); itsBrowsedDir = s.GetDirectory();
itsBrowsedDir = itsBrowsedDir.substr(0, itsBrowsedDir.rfind('/')); size_t last_slash = itsBrowsedDir.rfind('/');
if (last_slash != std::string::npos)
itsBrowsedDir = itsBrowsedDir.substr(0, last_slash);
else
itsBrowsedDir = "/";
if (itsBrowsedDir.empty()) if (itsBrowsedDir.empty())
itsBrowsedDir = "/"; itsBrowsedDir = "/";
Dirs->Clear(); Dirs->Clear();