Use lambdas for QtConcurrent::run instead of NewClosure
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <QAbstractItemModel>
|
||||
#include <QAbstractListModel>
|
||||
#include <QPersistentModelIndex>
|
||||
#include <QFuture>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QMultiMap>
|
||||
@@ -349,7 +348,7 @@ class Playlist : public QAbstractListModel {
|
||||
void QueueLayoutChanged();
|
||||
void SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &index);
|
||||
void ItemReloadComplete(const QPersistentModelIndex &index);
|
||||
void ItemsLoaded(QFuture<PlaylistItemList> future);
|
||||
void ItemsLoaded(PlaylistItemList items);
|
||||
void SongInsertVetoListenerDestroyed();
|
||||
void AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &result);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
#include <QtConcurrentRun>
|
||||
#include <QtConcurrent>
|
||||
#include <QFuture>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
@@ -42,7 +42,6 @@
|
||||
#include <QtDebug>
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/closure.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/player.h"
|
||||
#include "core/utilities.h"
|
||||
@@ -211,18 +210,11 @@ void PlaylistManager::Save(int id, const QString &filename, Playlist::Path path_
|
||||
}
|
||||
else {
|
||||
// Playlist is not in the playlist manager: probably save action was triggered from the left side bar and the playlist isn't loaded.
|
||||
QFuture<QList<Song>> future = QtConcurrent::run(playlist_backend_, &PlaylistBackend::GetPlaylistSongs, id);
|
||||
NewClosure(future, this, SLOT(ItemsLoadedForSavePlaylist(QFuture<SongList>, QString, Playlist::Path)), future, filename, path_type);
|
||||
(void)QtConcurrent::run([=]() { parser_->Save(playlist_backend_->GetPlaylistSongs(id), filename, path_type); });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PlaylistManager::ItemsLoadedForSavePlaylist(QFuture<SongList> future, const QString &filename, Playlist::Path path_type) {
|
||||
|
||||
parser_->Save(future.result(), filename, path_type);
|
||||
|
||||
}
|
||||
|
||||
void PlaylistManager::SaveWithUI(int id, const QString &playlist_name) {
|
||||
|
||||
QSettings settings;
|
||||
|
||||
@@ -215,7 +215,6 @@ class PlaylistManager : public PlaylistManagerInterface {
|
||||
void OneOfPlaylistsChanged();
|
||||
void UpdateSummaryText();
|
||||
void SongsDiscovered(const SongList& songs);
|
||||
void ItemsLoadedForSavePlaylist(QFuture<SongList> future, const QString& filename, Playlist::Path path_type);
|
||||
void PlaylistLoaded();
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QtConcurrentRun>
|
||||
#include <QtConcurrent>
|
||||
#include <QtAlgorithms>
|
||||
#include <QList>
|
||||
#include <QUrl>
|
||||
@@ -83,7 +83,7 @@ void SongLoaderInserter::Load(Playlist *destination, int row, bool play_now, boo
|
||||
deleteLater();
|
||||
}
|
||||
else {
|
||||
QtConcurrent::run(this, &SongLoaderInserter::AsyncLoad);
|
||||
(void)QtConcurrent::run([=]{ AsyncLoad(); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user