Skip to content

Commit

Permalink
Merge pull request #3998 from uklotzde/reimport-track-metadata
Browse files Browse the repository at this point in the history
Fix reimport of track metadata
  • Loading branch information
Holzhaus committed Jun 16, 2021
2 parents a17e944 + d30f3b1 commit 513da6d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/library/dlgtrackinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,11 @@ void DlgTrackInfo::slotImportMetadataFromFile() {
// losing existing metadata or to lose the beat grid by replacing
// it with a default grid created from an imprecise BPM.
// See also: https://bugs.launchpad.net/mixxx/+bug/1929311
mixxx::TrackMetadata trackMetadata = m_pLoadedTrack->getMetadata();
// In additiona we need to preserve all other track properties
// that are stored in TrackRecord, which serves as the underlying
// model for this dialog.
mixxx::TrackRecord trackRecord = m_pLoadedTrack->getRecord();
mixxx::TrackMetadata trackMetadata = trackRecord.getMetadata();
QImage coverImage;
const auto [importResult, metadataSynchronized] =
SoundSourceProxy(m_pLoadedTrack)
Expand All @@ -682,7 +686,6 @@ void DlgTrackInfo::slotImportMetadataFromFile() {
fileAccess.info(),
trackMetadata.getAlbumInfo().getTitle(),
coverImage);
mixxx::TrackRecord trackRecord;
trackRecord.replaceMetadataFromSource(
std::move(trackMetadata),
metadataSynchronized);
Expand Down
5 changes: 5 additions & 0 deletions src/track/trackrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ bool copyIfNotEmpty(
bool TrackRecord::replaceMetadataFromSource(
TrackMetadata&& importedMetadata,
const QDateTime& metadataSynchronized) {
if (m_streamInfoFromSource) {
// Preserve precise stream info if available, i.e. discard the
// audio properties that are also stored as track metadata.
importedMetadata.updateStreamInfoFromSource(*m_streamInfoFromSource);
}
bool modified = false;
if (getMetadata() != importedMetadata) {
setMetadata(std::move(importedMetadata));
Expand Down

0 comments on commit 513da6d

Please sign in to comment.