Partial revert commit af67de8
This commit is contained in:
@@ -1314,15 +1314,17 @@ void Playlist::Restore() {
|
||||
collection_items_by_id_.clear();
|
||||
|
||||
cancel_restore_ = false;
|
||||
|
||||
(void)QtConcurrent::run([=]() { ItemsLoaded(backend_->GetPlaylistItems(id_)); });
|
||||
QFuture<QList<PlaylistItemPtr>> future = QtConcurrent::run(backend_, &PlaylistBackend::GetPlaylistItems, id_);
|
||||
NewClosure(future, this, SLOT(ItemsLoaded(QFuture<PlaylistItemList>)), future);
|
||||
|
||||
}
|
||||
|
||||
void Playlist::ItemsLoaded(PlaylistItemList items) {
|
||||
void Playlist::ItemsLoaded(QFuture<PlaylistItemList> future) {
|
||||
|
||||
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()) {
|
||||
@@ -1351,7 +1353,7 @@ void Playlist::ItemsLoaded(PlaylistItemList items) {
|
||||
|
||||
// Should we gray out deleted songs asynchronously on startup?
|
||||
if (greyout) {
|
||||
(void)QtConcurrent::run([=]() { InvalidateDeletedSongs(); });
|
||||
QtConcurrent::run(this, &Playlist::InvalidateDeletedSongs);
|
||||
}
|
||||
|
||||
emit PlaylistLoaded();
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QAbstractItemModel>
|
||||
#include <QAbstractListModel>
|
||||
#include <QPersistentModelIndex>
|
||||
#include <QFuture>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QMultiMap>
|
||||
@@ -348,7 +349,7 @@ class Playlist : public QAbstractListModel {
|
||||
void QueueLayoutChanged();
|
||||
void SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &index);
|
||||
void ItemReloadComplete(const QPersistentModelIndex &index);
|
||||
void ItemsLoaded(PlaylistItemList items);
|
||||
void ItemsLoaded(QFuture<PlaylistItemList> future);
|
||||
void SongInsertVetoListenerDestroyed();
|
||||
void AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &result);
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <QtDebug>
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/closure.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/player.h"
|
||||
#include "core/utilities.h"
|
||||
@@ -210,11 +211,18 @@ 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.
|
||||
(void)QtConcurrent::run([=]() { parser_->Save(playlist_backend_->GetPlaylistSongs(id), filename, path_type); });
|
||||
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 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,6 +215,7 @@ 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:
|
||||
|
||||
@@ -83,7 +83,7 @@ void SongLoaderInserter::Load(Playlist *destination, int row, bool play_now, boo
|
||||
deleteLater();
|
||||
}
|
||||
else {
|
||||
(void)QtConcurrent::run([=]{ AsyncLoad(); });
|
||||
QtConcurrent::run(this, &SongLoaderInserter::AsyncLoad);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user