Always call QFutureWatcher::setFuture after connects
This commit is contained in:
@@ -431,11 +431,11 @@ void Playlist::ItemReload(const QPersistentModelIndex &idx, const Song &old_meta
|
||||
if (item) {
|
||||
QFuture<void> future = item->BackgroundReload();
|
||||
QFutureWatcher<void> *watcher = new QFutureWatcher<void>();
|
||||
watcher->setFuture(future);
|
||||
QObject::connect(watcher, &QFutureWatcher<void>::finished, this, [this, watcher, idx, old_metadata, metadata_edit]() {
|
||||
ItemReloadComplete(idx, old_metadata, metadata_edit);
|
||||
watcher->deleteLater();
|
||||
});
|
||||
watcher->setFuture(future);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1471,8 +1471,8 @@ void Playlist::Restore() {
|
||||
QFuture<PlaylistItemList> future = QtConcurrent::run(backend_, &PlaylistBackend::GetPlaylistItems, id_);
|
||||
#endif
|
||||
QFutureWatcher<PlaylistItemList> *watcher = new QFutureWatcher<PlaylistItemList>();
|
||||
watcher->setFuture(future);
|
||||
QObject::connect(watcher, &QFutureWatcher<PlaylistItemList>::finished, this, &Playlist::ItemsLoaded);
|
||||
watcher->setFuture(future);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -404,8 +404,8 @@ TagCompleter::TagCompleter(CollectionBackend *backend, Playlist::Column column,
|
||||
|
||||
QFuture<TagCompletionModel*> future = QtConcurrent::run(&InitCompletionModel, backend, column);
|
||||
QFutureWatcher<TagCompletionModel*> *watcher = new QFutureWatcher<TagCompletionModel*>();
|
||||
watcher->setFuture(future);
|
||||
QObject::connect(watcher, &QFutureWatcher<TagCompletionModel*>::finished, this, &TagCompleter::ModelReady);
|
||||
watcher->setFuture(future);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -226,11 +226,11 @@ void PlaylistManager::Save(const int id, const QString &filename, const Playlist
|
||||
QFuture<SongList> future = QtConcurrent::run(playlist_backend_, &PlaylistBackend::GetPlaylistSongs, id);
|
||||
#endif
|
||||
QFutureWatcher<SongList> *watcher = new QFutureWatcher<SongList>();
|
||||
watcher->setFuture(future);
|
||||
QObject::connect(watcher, &QFutureWatcher<SongList>::finished, this, [this, watcher, filename, path_type]() {
|
||||
ItemsLoadedForSavePlaylist(watcher->result(), filename, path_type);
|
||||
watcher->deleteLater();
|
||||
});
|
||||
watcher->setFuture(future);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user