search engine: fix assertion failure
This commit is contained in:
1
NEWS
1
NEWS
@@ -1,4 +1,5 @@
|
|||||||
ncmpcpp-0.7.2 (????-??-??)
|
ncmpcpp-0.7.2 (????-??-??)
|
||||||
|
* Attempt to add non-song item to playlist from search engine doesn't trigger assertion failure anymore.
|
||||||
|
|
||||||
ncmpcpp-0.7.1 (2016-01-01)
|
ncmpcpp-0.7.1 (2016-01-01)
|
||||||
* Selected songs in media library can now be added to playlists.
|
* Selected songs in media library can now be added to playlists.
|
||||||
|
|||||||
@@ -127,7 +127,19 @@ ConstSongIterator SearchEngineWindow::endS() const
|
|||||||
|
|
||||||
std::vector<MPD::Song> SearchEngineWindow::getSelectedSongs()
|
std::vector<MPD::Song> SearchEngineWindow::getSelectedSongs()
|
||||||
{
|
{
|
||||||
return {}; // TODO
|
std::vector<MPD::Song> result;
|
||||||
|
for (auto &item : *this)
|
||||||
|
{
|
||||||
|
if (item.isSelected())
|
||||||
|
{
|
||||||
|
assert(item.value().isSong());
|
||||||
|
result.push_back(item.value().song());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If no item is selected, add the current one if it's a song.
|
||||||
|
if (result.empty() && !empty() && current()->value().isSong())
|
||||||
|
result.push_back(current()->value().song());
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
@@ -336,22 +348,7 @@ bool SearchEngine::addItemToPlaylist(bool play)
|
|||||||
|
|
||||||
std::vector<MPD::Song> SearchEngine::getSelectedSongs()
|
std::vector<MPD::Song> SearchEngine::getSelectedSongs()
|
||||||
{
|
{
|
||||||
std::vector<MPD::Song> result;
|
return w.getSelectedSongs();
|
||||||
for (auto it = w.begin(); it != w.end(); ++it)
|
|
||||||
{
|
|
||||||
if (it->isSelected())
|
|
||||||
{
|
|
||||||
assert(it->value().isSong());
|
|
||||||
result.push_back(it->value().song());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if no item is selected, add current one
|
|
||||||
if (result.empty() && !w.empty())
|
|
||||||
{
|
|
||||||
assert(w.current()->value().isSong());
|
|
||||||
result.push_back(w.current()->value().song());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user