Always call QFutureWatcher::setFuture after connects

This commit is contained in:
Jonas Kvinge
2021-06-16 00:30:21 +02:00
parent d2d3f58a14
commit 8699790e78
15 changed files with 27 additions and 27 deletions

View File

@@ -617,7 +617,6 @@ void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const Song &song, co
QFuture<SongList> future = QtConcurrent::run(app_->collection_backend(), &CollectionBackend::GetAlbumSongs, song.effective_albumartist(), song.effective_album(), QueryOptions());
#endif
QFutureWatcher<SongList> *watcher = new QFutureWatcher<SongList>();
watcher->setFuture(future);
QObject::connect(watcher, &QFutureWatcher<SongList>::finished, this, [=]() {
SongList songs = watcher->result();
watcher->deleteLater();
@@ -634,6 +633,7 @@ void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const Song &song, co
cover_save_tasks_.insert(id, song);
}
});
watcher->setFuture(future);
}
else {
if (result.is_jpeg()) {
@@ -661,7 +661,6 @@ void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const Song &song, co
QFuture<SongList> future = QtConcurrent::run(app_->collection_backend(), &CollectionBackend::GetAlbumSongs, song.effective_albumartist(), song.effective_album(), QueryOptions());
#endif
QFutureWatcher<SongList> *watcher = new QFutureWatcher<SongList>();
watcher->setFuture(future);
QObject::connect(watcher, &QFutureWatcher<SongList>::finished, this, [=]() {
SongList songs = watcher->result();
watcher->deleteLater();
@@ -671,6 +670,7 @@ void AlbumCoverChoiceController::SaveCoverEmbeddedAutomatic(const Song &song, co
QMutexLocker l(&mutex_cover_save_tasks_);
cover_save_tasks_.insert(id, song);
});
watcher->setFuture(future);
}
else {
app_->album_cover_loader()->SaveEmbeddedCoverAsync(song.url().toLocalFile(), cover_filename);