From deddaed04a7a9e5e95b3d6a2be47f8c0f754ae17 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sat, 14 Nov 2020 02:13:22 +0100 Subject: [PATCH] Remove use of std::bind where possible --- src/collection/collectionmodel.cpp | 6 +++++- src/device/devicemanager.cpp | 6 +++++- src/dialogs/edittagdialog.cpp | 6 +++++- src/engine/gststartup.cpp | 6 +++++- src/organize/organizedialog.cpp | 7 +++++-- src/playlist/playlist.cpp | 12 ++++++++++-- src/playlist/playlistmanager.cpp | 6 +++++- src/playlist/songloaderinserter.cpp | 6 +++++- 8 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/collection/collectionmodel.cpp b/src/collection/collectionmodel.cpp index 13d682050..c74f5d984 100644 --- a/src/collection/collectionmodel.cpp +++ b/src/collection/collectionmodel.cpp @@ -893,7 +893,11 @@ void CollectionModel::LazyPopulate(CollectionItem *parent, const bool signal) { } void CollectionModel::ResetAsync() { - QFuture future = QtConcurrent::run(std::bind(&CollectionModel::RunQuery, this, root_)); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QFuture future = QtConcurrent::run(&CollectionModel::RunQuery, this, root_); +#else + QFuture future = QtConcurrent::run(this, &CollectionModel::RunQuery, root_); +#endif NewClosure(future, this, SLOT(ResetAsyncQueryFinished(QFuture)), future); } diff --git a/src/device/devicemanager.cpp b/src/device/devicemanager.cpp index 54ea86cf2..9faf69129 100644 --- a/src/device/devicemanager.cpp +++ b/src/device/devicemanager.cpp @@ -102,7 +102,11 @@ DeviceManager::DeviceManager(Application *app, QObject *parent) connect(this, SIGNAL(DeviceCreatedFromDB(DeviceInfo*)), SLOT(AddDeviceFromDB(DeviceInfo*))); // This reads from the database and contents on the database mutex, which can be very slow on startup. - (void)QtConcurrent::run(&thread_pool_, std::bind(&DeviceManager::LoadAllDevices, this)); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + (void)QtConcurrent::run(&thread_pool_, &DeviceManager::LoadAllDevices, this); +#else + (void)QtConcurrent::run(&thread_pool_, this, &DeviceManager::LoadAllDevices); +#endif // This proxy model only shows connected devices connected_devices_model_ = new DeviceStateFilterModel(this); diff --git a/src/dialogs/edittagdialog.cpp b/src/dialogs/edittagdialog.cpp index fcfc61251..bf69000b3 100644 --- a/src/dialogs/edittagdialog.cpp +++ b/src/dialogs/edittagdialog.cpp @@ -293,7 +293,11 @@ void EditTagDialog::SetSongs(const SongList &s, const PlaylistItemList &items) { ui_->song_list->clear(); // Reload tags in the background - QFuture> future = QtConcurrent::run(std::bind(&EditTagDialog::LoadData, this, s)); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QFuture> future = QtConcurrent::run(&EditTagDialog::LoadData, this, s); +#else + QFuture> future = QtConcurrent::run(this, &EditTagDialog::LoadData, s); +#endif NewClosure(future, this, SLOT(SetSongsFinished(QFuture>)), future); } diff --git a/src/engine/gststartup.cpp b/src/engine/gststartup.cpp index a067ca427..1dd6921d3 100644 --- a/src/engine/gststartup.cpp +++ b/src/engine/gststartup.cpp @@ -41,7 +41,11 @@ #include "gststartup.h" GstStartup::GstStartup(QObject *parent) : QObject(parent) { - initializing_ = QtConcurrent::run([=]{ InitializeGStreamer(); }); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + initializing_ = QtConcurrent::run(&GstStartup::InitializeGStreamer, this); +#else + initializing_ = QtConcurrent::run(this, &GstStartup::InitializeGStreamer); +#endif } GstStartup::~GstStartup() {} diff --git a/src/organize/organizedialog.cpp b/src/organize/organizedialog.cpp index 0b5a1e3b2..94ff299e1 100644 --- a/src/organize/organizedialog.cpp +++ b/src/organize/organizedialog.cpp @@ -387,8 +387,11 @@ bool OrganizeDialog::SetUrls(const QList &urls) { } bool OrganizeDialog::SetFilenames(const QStringList &filenames) { - - songs_future_ = QtConcurrent::run(std::bind(&OrganizeDialog::LoadSongsBlocking, this, filenames)); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + songs_future_ = QtConcurrent::run(&OrganizeDialog::LoadSongsBlocking, this, filenames); +#else + songs_future_ = QtConcurrent::run(this, &OrganizeDialog::LoadSongsBlocking, filenames); +#endif NewClosure(songs_future_, [=]() { SetSongs(songs_future_.result()); }); SetLoadingSongs(true); diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 4664990bf..919d8aafe 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -1406,7 +1406,11 @@ void Playlist::Restore() { collection_items_by_id_.clear(); cancel_restore_ = false; - QFuture> future = QtConcurrent::run(std::bind(&PlaylistBackend::GetPlaylistItems, backend_, id_)); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QFuture> future = QtConcurrent::run(&PlaylistBackend::GetPlaylistItems, backend_, id_); +#else + QFuture> future = QtConcurrent::run(backend_, &PlaylistBackend::GetPlaylistItems, id_); +#endif NewClosure(future, this, SLOT(ItemsLoaded(QFuture)), future); } @@ -1461,7 +1465,11 @@ void Playlist::ItemsLoaded(QFuture future) { // Should we gray out deleted songs asynchronously on startup? if (greyout) { - (void)QtConcurrent::run(std::bind(&Playlist::InvalidateDeletedSongs, this)); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + (void)QtConcurrent::run(&Playlist::InvalidateDeletedSongs, this); +#else + (void)QtConcurrent::run(this, &Playlist::InvalidateDeletedSongs); +#endif } emit PlaylistLoaded(); diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index d86f296d9..2e8bc772c 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -215,7 +215,11 @@ void PlaylistManager::Save(const int id, const QString &filename, const Playlist } 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> future = QtConcurrent::run(std::bind(&PlaylistBackend::GetPlaylistSongs, playlist_backend_, id)); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QFuture> future = QtConcurrent::run(&PlaylistBackend::GetPlaylistSongs, playlist_backend_, id); +#else + QFuture> future = QtConcurrent::run(playlist_backend_, &PlaylistBackend::GetPlaylistSongs, id); +#endif NewClosure(future, this, SLOT(ItemsLoadedForSavePlaylist(QFuture, QString, Playlist::Path)), future, filename, path_type); } diff --git a/src/playlist/songloaderinserter.cpp b/src/playlist/songloaderinserter.cpp index 7483e9eb3..faece99f2 100644 --- a/src/playlist/songloaderinserter.cpp +++ b/src/playlist/songloaderinserter.cpp @@ -83,7 +83,11 @@ void SongLoaderInserter::Load(Playlist *destination, int row, bool play_now, boo deleteLater(); } else { - (void)QtConcurrent::run([=]{ AsyncLoad(); }); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + (void)QtConcurrent::run(&SongLoaderInserter::AsyncLoad, this); +#else + (void)QtConcurrent::run(this, &SongLoaderInserter::AsyncLoad); +#endif } }