diff --git a/src/platform/qt/GBAApp.cpp b/src/platform/qt/GBAApp.cpp index e21dbef05..99c5cb180 100644 --- a/src/platform/qt/GBAApp.cpp +++ b/src/platform/qt/GBAApp.cpp @@ -274,17 +274,17 @@ QNetworkReply* GBAApp::httpGet(const QUrl& url) { return m_netman.get(req); } -qint64 GBAApp::submitWorkerJob(std::function job, std::function callback) { - return submitWorkerJob(job, nullptr, callback); +qint64 GBAApp::submitWorkerJob(std::function&& job, std::function&& callback) { + return submitWorkerJob(std::move(job), nullptr, std::move(callback)); } -qint64 GBAApp::submitWorkerJob(std::function job, QObject* context, std::function callback) { +qint64 GBAApp::submitWorkerJob(std::function&& job, QObject* context, std::function&& callback) { qint64 jobId = m_nextJob; ++m_nextJob; - WorkerJob* jobRunnable = new WorkerJob(jobId, job, this); + WorkerJob* jobRunnable = new WorkerJob(jobId, std::move(job), this); m_workerJobs.insert(jobId, jobRunnable); if (callback) { - waitOnJob(jobId, context, callback); + waitOnJob(jobId, context, std::move(callback)); } m_workerThreads.start(jobRunnable); return jobId; @@ -308,7 +308,7 @@ bool GBAApp::removeWorkerJob(qint64 jobId) { return success; } -bool GBAApp::waitOnJob(qint64 jobId, QObject* context, std::function callback) { +bool GBAApp::waitOnJob(qint64 jobId, QObject* context, std::function&& callback) { if (!m_workerJobs.contains(jobId)) { return false; } @@ -396,7 +396,7 @@ void GBAApp::finishJob(qint64 jobId) { m_workerJobCallbacks.remove(jobId); } -GBAApp::WorkerJob::WorkerJob(qint64 id, std::function job, GBAApp* owner) +GBAApp::WorkerJob::WorkerJob(qint64 id, std::function&& job, GBAApp* owner) : m_id(id) , m_job(job) , m_owner(owner) diff --git a/src/platform/qt/GBAApp.h b/src/platform/qt/GBAApp.h index e9907685f..2388bc297 100644 --- a/src/platform/qt/GBAApp.h +++ b/src/platform/qt/GBAApp.h @@ -74,10 +74,10 @@ public: QNetworkAccessManager* netman(); QNetworkReply* httpGet(const QUrl&); - qint64 submitWorkerJob(std::function job, std::function callback = {}); - qint64 submitWorkerJob(std::function job, QObject* context, std::function callback); + qint64 submitWorkerJob(std::function&& job, std::function&& callback = {}); + qint64 submitWorkerJob(std::function&& job, QObject* context, std::function&& callback); bool removeWorkerJob(qint64 jobId); - bool waitOnJob(qint64 jobId, QObject* context, std::function callback); + bool waitOnJob(qint64 jobId, QObject* context, std::function&& callback); ApplicationUpdater* updater() { return &m_updater; } QString invokeOnExit() { return m_invokeOnExit; } @@ -103,7 +103,7 @@ private slots: private: class WorkerJob : public QRunnable { public: - WorkerJob(qint64 id, std::function job, GBAApp* owner); + WorkerJob(qint64 id, std::function&& job, GBAApp* owner); public: void run() override;