Partial revert commit af67de8

This commit is contained in:
Jonas Kvinge
2020-07-19 19:07:12 +02:00
parent e043a03eb6
commit ff73dd2183
11 changed files with 39 additions and 17 deletions

View File

@@ -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();