FIX: Tag fetcher applies incorrect tags for songs without any results

Before this fix the fetched data of the first title was applied to all selected titles. If the other titles hat correctly fetched tags, this information was overridden by the correct data. So the error only occured in case of failure during fetching.
This commit is contained in:
terrorfisch 2015-10-30 12:44:12 +01:00
parent 240605a011
commit c75f046c10
1 changed files with 26 additions and 20 deletions

View File

@ -842,26 +842,32 @@ void EditTagDialog::FetchTagSongChosen(const Song& original_song,
const QString filename = original_song.url().toLocalFile();
// Find the song with this filename
for (int i = 0; i < data_.count(); ++i) {
Data* data = &data_[i];
if (data->original_.url().toLocalFile() != filename) continue;
int id;
for (id = 0; id < data_.count(); ++id)
if (data_[id].original_.url().toLocalFile() == filename)
break;
// Is it currently being displayed in the UI?
if (ui_->song_list->currentRow() == i) {
// Yes! We can just set the fields in the UI
ui_->title->set_text(new_metadata.title());
ui_->artist->set_text(new_metadata.artist());
ui_->album->set_text(new_metadata.album());
ui_->track->setValue(new_metadata.track());
ui_->year->setValue(new_metadata.year());
} else {
data->current_.set_title(new_metadata.title());
data->current_.set_artist(new_metadata.artist());
data->current_.set_album(new_metadata.album());
data->current_.set_track(new_metadata.track());
data->current_.set_year(new_metadata.year());
if( id == data_.count() ) {
qLog(Warning) << "Could not find song to filename: " << filename;
return;
}
Data& data = data_[id];
data.current_.set_title(new_metadata.title());
data.current_.set_artist(new_metadata.artist());
data.current_.set_album(new_metadata.album());
data.current_.set_track(new_metadata.track());
data.current_.set_year(new_metadata.year());
// Is it currently selected in the UI?
QModelIndexList selection =
ui_->song_list->selectionModel()->selectedRows();
for( const QModelIndex& i : selection ) {
if ( i.row() == id ) {
// We need to update view
for (const FieldData& field : fields_)
InitFieldValue(field, selection);
break;
}
}
}