Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/library/coverartutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,19 @@ void CoverInfoGuesser::guessAndSetCoverInfoForTracks(
}
}

void guessTrackCoverInfoConcurrently(
QFuture<void> guessTrackCoverInfoConcurrently(
TrackPointer pTrack) {
VERIFY_OR_DEBUG_ASSERT(pTrack) {
return;
return {};
}
if (s_enableConcurrentGuessingOfTrackCoverInfo) {
QtConcurrent::run([pTrack] {
return QtConcurrent::run([pTrack] {
CoverInfoGuesser().guessAndSetCoverInfoForTrack(*pTrack);
});
} else {
// Disabled only during tests
CoverInfoGuesser().guessAndSetCoverInfoForTrack(*pTrack);
return {};
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/library/coverartutils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <QFuture>
#include <QImage>
#include <QList>
#include <QSize>
Expand Down Expand Up @@ -93,7 +94,7 @@ class CoverInfoGuesser {
// Guesses the cover art for the provided tracks by searching the tracks'
// metadata and folders for image files. All I/O is done in a separate
// thread.
void guessTrackCoverInfoConcurrently(TrackPointer pTrack);
[[nodiscard]] QFuture<void> guessTrackCoverInfoConcurrently(TrackPointer pTrack);

// Concurrent guessing of track covers during short running
// tests may cause spurious test failures due to timing issues.
Expand Down
4 changes: 3 additions & 1 deletion src/library/dao/trackdao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2181,7 +2181,9 @@ TrackPointer TrackDAO::getOrAddTrack(

// If the track wasn't in the library already then it has not yet
// been checked for cover art.
guessTrackCoverInfoConcurrently(pTrack);
const auto future = guessTrackCoverInfoConcurrently(pTrack);
// Don't wait for the result and keep running in the background
Q_UNUSED(future)

return pTrack;
}
Expand Down
4 changes: 3 additions & 1 deletion src/widget/wcoverart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ void WCoverArt::slotReloadCoverArt() {
if (!m_loadedTrack) {
return;
}
guessTrackCoverInfoConcurrently(m_loadedTrack);
const auto future = guessTrackCoverInfoConcurrently(m_loadedTrack);
// Don't wait for the result and keep running in the background
Q_UNUSED(future)
}

void WCoverArt::slotCoverInfoSelected(const CoverInfoRelative& coverInfo) {
Expand Down
4 changes: 3 additions & 1 deletion src/widget/wspinny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ void WSpinny::slotReloadCoverArt() {
if (!m_loadedTrack) {
return;
}
guessTrackCoverInfoConcurrently(m_loadedTrack);
const auto future = guessTrackCoverInfoConcurrently(m_loadedTrack);
// Don't wait for the result and keep running in the background
Q_UNUSED(future)
}

void WSpinny::paintEvent(QPaintEvent *e) {
Expand Down