Use lambdas for QtConcurrent::run instead of NewClosure

This commit is contained in:
Jonas Kvinge
2020-07-18 16:28:39 +02:00
parent 425dac478e
commit af67de8aa6
12 changed files with 25 additions and 47 deletions

View File

@@ -33,7 +33,7 @@
#include <QtGlobal>
#include <QObject>
#include <QCoreApplication>
#include <QtConcurrentRun>
#include <QtConcurrent>
#include <QFuture>
#include <QIODevice>
#include <QDataStream>
@@ -1314,17 +1314,15 @@ void Playlist::Restore() {
collection_items_by_id_.clear();
cancel_restore_ = false;
QFuture<QList<PlaylistItemPtr>> future = QtConcurrent::run(backend_, &PlaylistBackend::GetPlaylistItems, id_);
NewClosure(future, this, SLOT(ItemsLoaded(QFuture<PlaylistItemList>)), future);
(void)QtConcurrent::run([=]() { ItemsLoaded(backend_->GetPlaylistItems(id_)); });
}
void Playlist::ItemsLoaded(QFuture<PlaylistItemList> future) {
void Playlist::ItemsLoaded(PlaylistItemList items) {
if (cancel_restore_) return;
PlaylistItemList items = future.result();
// Backend returns empty elements for collection items which it couldn't match (because they got deleted); we don't need those
QMutableListIterator<PlaylistItemPtr> it(items);
while (it.hasNext()) {
@@ -1353,7 +1351,7 @@ void Playlist::ItemsLoaded(QFuture<PlaylistItemList> future) {
// Should we gray out deleted songs asynchronously on startup?
if (greyout) {
QtConcurrent::run(this, &Playlist::InvalidateDeletedSongs);
(void)QtConcurrent::run([=]() { InvalidateDeletedSongs(); });
}
emit PlaylistLoaded();