aboutsummaryrefslogtreecommitdiff
path: root/launcher/tasks/ConcurrentTask.cpp
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2023-04-07 19:44:57 -0700
committerRachel Powers <508861+Ryex@users.noreply.github.com>2023-05-01 10:48:00 -0700
commit236764adf6cb985dfc6d00b9cbcba8eb176510ed (patch)
tree61708da2a77617c2a0a4810b0cc52ed6c6959bd4 /launcher/tasks/ConcurrentTask.cpp
parenta80b4255515b1f3e61d12aeefcef6bf16ac4ee6b (diff)
downloadPrismLauncher-236764adf6cb985dfc6d00b9cbcba8eb176510ed.tar.gz
PrismLauncher-236764adf6cb985dfc6d00b9cbcba8eb176510ed.tar.bz2
PrismLauncher-236764adf6cb985dfc6d00b9cbcba8eb176510ed.zip
refactor: Qt can handle const& in signals and slots
While most Qt types cna use implicit data sharing pasing our own structs means copies. const& ensure it's only copied as needed by Qt. Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'launcher/tasks/ConcurrentTask.cpp')
-rw-r--r--launcher/tasks/ConcurrentTask.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index 439879e6..37435739 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -133,7 +133,7 @@ void ConcurrentTask::startNext()
connect(next.get(), &Task::status, this, [this, next](QString msg) { subTaskStatus(next, msg); });
connect(next.get(), &Task::details, this, [this, next](QString msg) { subTaskDetails(next, msg); });
- connect(next.get(), &Task::stepProgress, this, [this, next](TaskStepProgress tp) { subTaskStepProgress(next, tp); });
+ connect(next.get(), &Task::stepProgress, this, [this, next](TaskStepProgress const& tp) { subTaskStepProgress(next, tp); });
connect(next.get(), &Task::progress, this, [this, next](qint64 current, qint64 total) { subTaskProgress(next, current, total); });
@@ -224,13 +224,15 @@ void ConcurrentTask::subTaskProgress(Task::Ptr task, qint64 current, qint64 tota
updateState();
}
-void ConcurrentTask::subTaskStepProgress(Task::Ptr task, TaskStepProgress task_progress)
+void ConcurrentTask::subTaskStepProgress(Task::Ptr task, TaskStepProgress const& task_progress)
{
Operation op = Operation::ADDED;
if (!m_task_progress.contains(task_progress.uid)) {
m_task_progress.insert(task_progress.uid, std::make_shared<TaskStepProgress>(task_progress));
op = Operation::ADDED;
+ emit stepProgress(task_progress);
+ updateStepProgress(task_progress, op);
} else {
auto tp = m_task_progress.value(task_progress.uid);
@@ -243,10 +245,10 @@ void ConcurrentTask::subTaskStepProgress(Task::Ptr task, TaskStepProgress task_p
tp->details = task_progress.details;
op = Operation::CHANGED;
+ emit stepProgress(*tp.get());
+ updateStepProgress(*tp.get(), op);
}
- emit stepProgress(task_progress);
- updateStepProgress(task_progress, op);
}
void ConcurrentTask::updateStepProgress(TaskStepProgress const& changed_progress, Operation op)