From 5e757ff999ae7996ed74cc5fd00c553161d2bcac Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Wed, 4 Feb 2009 18:50:22 +0100 Subject: [PATCH] fix/improve detecting playlist's changes --- src/status_checker.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/status_checker.cpp b/src/status_checker.cpp index 1dfd4776..ba9aa191 100644 --- a/src/status_checker.cpp +++ b/src/status_checker.cpp @@ -189,8 +189,18 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) mPlaylist->Reserve(playlist_length); for (SongList::const_iterator it = list.begin(); it != list.end(); it++) { - mPlaylist->AddOption(**it, now_playing == (*it)->GetPosition()); - mPlaylist->Back().CopyPtr(0); + int pos = (*it)->GetPosition(); + 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(); }