fix/improve detecting playlist's changes

This commit is contained in:
Andrzej Rybczak
2009-02-04 18:50:22 +01:00
parent 34ba81be9e
commit 5e757ff999

View File

@@ -189,8 +189,18 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
mPlaylist->Reserve(playlist_length); mPlaylist->Reserve(playlist_length);
for (SongList::const_iterator it = list.begin(); it != list.end(); it++) for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
{ {
mPlaylist->AddOption(**it, now_playing == (*it)->GetPosition()); int pos = (*it)->GetPosition();
mPlaylist->Back().CopyPtr(0); if (pos < int(mPlaylist->Size()))
{
// if song's already in playlist, replace it with a new one
mPlaylist->at(pos) = **it;
}
else
{
// otherwise just add it to playlist
mPlaylist->AddOption(**it, now_playing == pos);
}
mPlaylist->at(pos).CopyPtr(0);
(*it)->NullMe(); (*it)->NullMe();
} }