Skip to content

Commit

Permalink
Merge pull request #4904 from daschuer/lp1905124
Browse files Browse the repository at this point in the history
Dispose Track::refreshCoverImageDigest() reading covers from the main thread
  • Loading branch information
Swiftb0y authored Aug 21, 2022
2 parents 600a574 + e74f02f commit 6aa07cd
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 35 deletions.
3 changes: 0 additions & 3 deletions src/library/dao/trackdao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1567,9 +1567,6 @@ TrackPointer TrackDAO::getTrackById(TrackId trackId) const {
}
}

// Validate and refresh cover image hash values if needed.
pTrack->refreshCoverImageDigest();

// Listen to signals from Track objects and forward them to
// receivers. TrackDAO works as a relay for selected track signals
// that allows receivers to use permanent connections with
Expand Down
24 changes: 0 additions & 24 deletions src/track/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,30 +1428,6 @@ void Track::setCoverInfo(const CoverInfoRelative& coverInfo) {
}
}

bool Track::refreshCoverImageDigest(
const QImage& loadedImage) {
auto locked = lockMutex(&m_qMutex);
auto coverInfo = CoverInfo(
m_record.getCoverInfo(),
m_fileAccess.info().location());
if (!coverInfo.refreshImageDigest(
loadedImage,
m_fileAccess.token())) {
return false;
}
if (!compareAndSet(
m_record.ptrCoverInfo(),
static_cast<const CoverInfoRelative&>(coverInfo))) {
return false;
}
kLogger.info()
<< "Refreshed cover image digest"
<< m_fileAccess.info().location();
markDirtyAndUnlock(&locked);
emit coverArtUpdated();
return true;
}

CoverInfoRelative Track::getCoverInfo() const {
const auto locked = lockMutex(&m_qMutex);
return m_record.getCoverInfo();
Expand Down
6 changes: 0 additions & 6 deletions src/track/track.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,6 @@ class Track : public QObject {
void setCoverInfo(const CoverInfoRelative& coverInfo);
CoverInfoRelative getCoverInfo() const;
CoverInfo getCoverInfoWithLocation() const;
// Verify the cover image hash and update it if necessary.
// If the corresponding image has already been loaded it
// could be provided as a parameter to avoid reloading
// if actually needed.
bool refreshCoverImageDigest(
const QImage& loadedImage = QImage());

/// Set track metadata after importing from the source.
///
Expand Down
2 changes: 1 addition & 1 deletion src/widget/wcoverart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void WCoverArt::slotCoverFound(
mixxx::cache_key_t requestedCacheKey,
bool coverInfoUpdated) {
Q_UNUSED(requestedCacheKey);
Q_UNUSED(coverInfoUpdated);
Q_UNUSED(coverInfoUpdated); // CoverArtCache has taken care, updating the Track.
if (!m_bEnable) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/widget/wspinny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void WSpinny::slotCoverFound(
mixxx::cache_key_t requestedCacheKey,
bool coverInfoUpdated) {
Q_UNUSED(requestedCacheKey);
Q_UNUSED(coverInfoUpdated);
Q_UNUSED(coverInfoUpdated); // CoverArtCache has taken care, updating the Track.
if (pRequestor == this &&
m_loadedTrack &&
m_loadedTrack->getLocation() == coverInfo.trackLocation) {
Expand Down

0 comments on commit 6aa07cd

Please sign in to comment.