Qt: Coverity complains about this but I have no idea if it matters

This commit is contained in:
Vicki Pfau 2024-01-30 16:16:36 -08:00
parent 4cdcfe6dd3
commit eff1785ce0
2 changed files with 11 additions and 11 deletions

View File

@ -274,17 +274,17 @@ QNetworkReply* GBAApp::httpGet(const QUrl& url) {
return m_netman.get(req);
}
qint64 GBAApp::submitWorkerJob(std::function<void ()> job, std::function<void ()> callback) {
return submitWorkerJob(job, nullptr, callback);
qint64 GBAApp::submitWorkerJob(std::function<void ()>&& job, std::function<void ()>&& callback) {
return submitWorkerJob(std::move(job), nullptr, std::move(callback));
}
qint64 GBAApp::submitWorkerJob(std::function<void ()> job, QObject* context, std::function<void ()> callback) {
qint64 GBAApp::submitWorkerJob(std::function<void ()>&& job, QObject* context, std::function<void ()>&& 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<void ()> callback) {
bool GBAApp::waitOnJob(qint64 jobId, QObject* context, std::function<void ()>&& 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<void ()> job, GBAApp* owner)
GBAApp::WorkerJob::WorkerJob(qint64 id, std::function<void ()>&& job, GBAApp* owner)
: m_id(id)
, m_job(job)
, m_owner(owner)

View File

@ -74,10 +74,10 @@ public:
QNetworkAccessManager* netman();
QNetworkReply* httpGet(const QUrl&);
qint64 submitWorkerJob(std::function<void ()> job, std::function<void ()> callback = {});
qint64 submitWorkerJob(std::function<void ()> job, QObject* context, std::function<void ()> callback);
qint64 submitWorkerJob(std::function<void ()>&& job, std::function<void ()>&& callback = {});
qint64 submitWorkerJob(std::function<void ()>&& job, QObject* context, std::function<void ()>&& callback);
bool removeWorkerJob(qint64 jobId);
bool waitOnJob(qint64 jobId, QObject* context, std::function<void ()> callback);
bool waitOnJob(qint64 jobId, QObject* context, std::function<void ()>&& 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<void ()> job, GBAApp* owner);
WorkerJob(qint64 id, std::function<void ()>&& job, GBAApp* owner);
public:
void run() override;