Skip to content

Commit dc56b97

Browse files
committed
CmrtGroupingService: Purge overlaying members' cached Tracks on re-election
1 parent 40451be commit dc56b97

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/musicbrainz/cmrtgroupingservice.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "analyzer/qualityscorer.h"
77
#include "library/library_prefs.h"
8+
#include "track/globaltrackcache.h"
89

910
namespace mixxx {
1011

@@ -364,6 +365,24 @@ void CmrtGroupingService::replaceCanonical(int groupId,
364365
qDebug() << "CmrtGroupingService -> [replaceCanonical] -> done, recalculated"
365366
<< existingMembers.size() << "other member offset(s)";
366367
}
368+
369+
// any member with use_cmrt_data=true was overlaying
370+
// (via Track::applyCmrtOverlay()) a TrackPointer to the now-demoted
371+
// oldCanonicalId. GlobalTrackCacheLocker().purgeTrackId() on each
372+
// overlaying member forces the next getTrackById() to reconstruct the
373+
// Track from scratch, which re-runs applyCmrtOverlayIfConfigured()
374+
// against the new canonical
375+
for (const CmrtMember& member : existingMembers) {
376+
if (member.useCmrtData) {
377+
GlobalTrackCacheLocker().purgeTrackId(member.trackId);
378+
}
379+
}
380+
if (newMember.useCmrtData) {
381+
// Shouldn't normally be true for a track that just became
382+
// canonical (there's nothing to overlay onto itself), but purge
383+
// defensively in case the flag was set before this election ran.
384+
GlobalTrackCacheLocker().purgeTrackId(newCanonicalId);
385+
}
367386
}
368387

369388
} // namespace mixxx

0 commit comments

Comments
 (0)