check for emptiness in some more places
these containers can be empty escpecially if one wants to go for a trip around ncmpcpp screens while connection to mpd is lost. this is highly unlikely to happen, but should be secured anyway.
This commit is contained in:
@@ -254,6 +254,8 @@ void Browser::ReverseSelection()
|
|||||||
|
|
||||||
void Browser::GetSelectedSongs(MPD::SongList &v)
|
void Browser::GetSelectedSongs(MPD::SongList &v)
|
||||||
{
|
{
|
||||||
|
if (w->Empty())
|
||||||
|
return;
|
||||||
std::vector<size_t> selected;
|
std::vector<size_t> selected;
|
||||||
w->GetSelected(selected);
|
w->GetSelected(selected);
|
||||||
if (selected.empty())
|
if (selected.empty())
|
||||||
|
|||||||
@@ -280,6 +280,8 @@ MPD::Song *Playlist::CurrentSong()
|
|||||||
|
|
||||||
void Playlist::GetSelectedSongs(MPD::SongList &v)
|
void Playlist::GetSelectedSongs(MPD::SongList &v)
|
||||||
{
|
{
|
||||||
|
if (myPlaylist->Items->Empty())
|
||||||
|
return;
|
||||||
std::vector<size_t> selected;
|
std::vector<size_t> selected;
|
||||||
Items->GetSelected(selected);
|
Items->GetSelected(selected);
|
||||||
if (selected.empty())
|
if (selected.empty())
|
||||||
|
|||||||
@@ -233,6 +233,8 @@ MPD::Song *SearchEngine::CurrentSong()
|
|||||||
|
|
||||||
void SearchEngine::GetSelectedSongs(MPD::SongList &v)
|
void SearchEngine::GetSelectedSongs(MPD::SongList &v)
|
||||||
{
|
{
|
||||||
|
if (w->Empty())
|
||||||
|
return;
|
||||||
std::vector<size_t> selected;
|
std::vector<size_t> selected;
|
||||||
w->GetSelected(selected);
|
w->GetSelected(selected);
|
||||||
if (selected.empty() && w->Choice() >= StaticOptions)
|
if (selected.empty() && w->Choice() >= StaticOptions)
|
||||||
|
|||||||
@@ -285,14 +285,17 @@ void TagEditor::Update()
|
|||||||
MPD::SongList list;
|
MPD::SongList list;
|
||||||
if (Config.albums_in_tag_editor)
|
if (Config.albums_in_tag_editor)
|
||||||
{
|
{
|
||||||
Mpd.StartSearch(1);
|
if (!Albums->Empty())
|
||||||
Mpd.AddSearch(MPD_TAG_ALBUM, Albums->Current().second);
|
|
||||||
Mpd.CommitSearch(list);
|
|
||||||
sort(list.begin(), list.end(), CaseInsensitiveSorting());
|
|
||||||
for (MPD::SongList::iterator it = list.begin(); it != list.end(); ++it)
|
|
||||||
{
|
{
|
||||||
(*it)->Localize();
|
Mpd.StartSearch(1);
|
||||||
Tags->AddOption(**it);
|
Mpd.AddSearch(MPD_TAG_ALBUM, Albums->Current().second);
|
||||||
|
Mpd.CommitSearch(list);
|
||||||
|
sort(list.begin(), list.end(), CaseInsensitiveSorting());
|
||||||
|
for (MPD::SongList::iterator it = list.begin(); it != list.end(); ++it)
|
||||||
|
{
|
||||||
|
(*it)->Localize();
|
||||||
|
Tags->AddOption(**it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user