Fix updating playlist songs when there are multiple files with the same URL
Fixes #501
This commit is contained in:
parent
a4f692c788
commit
d16a26605e
|
@ -1022,7 +1022,7 @@ void Playlist::InsertInternetItems(InternetService *service, const SongList &son
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::UpdateItems(const SongList &songs) {
|
void Playlist::UpdateItems(SongList songs) {
|
||||||
|
|
||||||
qLog(Debug) << "Updating playlist with new tracks' info";
|
qLog(Debug) << "Updating playlist with new tracks' info";
|
||||||
|
|
||||||
|
@ -1032,16 +1032,13 @@ void Playlist::UpdateItems(const SongList &songs) {
|
||||||
// then we remove song from our list because we will not need to check it again.
|
// then we remove song from our list because we will not need to check it again.
|
||||||
// And we also update undo actions.
|
// And we also update undo actions.
|
||||||
|
|
||||||
QList<Song> songs_list;
|
|
||||||
for (const Song &song : songs) songs_list.append(song);
|
|
||||||
|
|
||||||
for (int i = 0; i < items_.size() ; i++) {
|
for (int i = 0; i < items_.size() ; i++) {
|
||||||
// Update current items list
|
// Update current items list
|
||||||
QMutableListIterator<Song> it(songs_list);
|
QMutableListIterator<Song> it(songs);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
const Song &song = it.next();
|
const Song &song = it.next();
|
||||||
const PlaylistItemPtr &item = items_[i];
|
const PlaylistItemPtr &item = items_[i];
|
||||||
if (item->Metadata().url() == song.url()) {
|
if (item->Metadata().url() == song.url() && (item->Metadata().filetype() == Song::FileType_Unknown || item->Metadata().filetype() == Song::FileType_Stream || item->Metadata().filetype() == Song::FileType_CDDA)) {
|
||||||
PlaylistItemPtr new_item;
|
PlaylistItemPtr new_item;
|
||||||
if (song.is_collection_song()) {
|
if (song.is_collection_song()) {
|
||||||
new_item = PlaylistItemPtr(new CollectionPlaylistItem(song));
|
new_item = PlaylistItemPtr(new CollectionPlaylistItem(song));
|
||||||
|
|
|
@ -288,7 +288,7 @@ class Playlist : public QAbstractListModel {
|
||||||
void ClearStreamMetadata();
|
void ClearStreamMetadata();
|
||||||
void SetStreamMetadata(const QUrl &url, const Song &song, const bool minor);
|
void SetStreamMetadata(const QUrl &url, const Song &song, const bool minor);
|
||||||
void ItemChanged(PlaylistItemPtr item);
|
void ItemChanged(PlaylistItemPtr item);
|
||||||
void UpdateItems(const SongList &songs);
|
void UpdateItems(SongList songs);
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
void RemoveDuplicateSongs();
|
void RemoveDuplicateSongs();
|
||||||
|
|
Loading…
Reference in New Issue