aboutsummaryrefslogtreecommitdiff
path: root/launcher/tasks/ConcurrentTask.cpp
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-08-15 12:16:00 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-08-15 12:16:00 +0300
commitc94ee67077076fdfb3ad04e93a0de2ae32b6a4e5 (patch)
tree437dec3be224cae5e229eeaa4ac9ebeedffd03e3 /launcher/tasks/ConcurrentTask.cpp
parent019e5ca3e819f5daf9933bc0fb091784b0ca561f (diff)
parent8f5bb982cd27dd9158b63d826769c168455a139b (diff)
downloadPrismLauncher-c94ee67077076fdfb3ad04e93a0de2ae32b6a4e5.tar.gz
PrismLauncher-c94ee67077076fdfb3ad04e93a0de2ae32b6a4e5.tar.bz2
PrismLauncher-c94ee67077076fdfb3ad04e93a0de2ae32b6a4e5.zip
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into curseforge-url-handle3
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/tasks/ConcurrentTask.cpp')
-rw-r--r--launcher/tasks/ConcurrentTask.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index 9aada5e6..6cfd864c 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -88,6 +88,7 @@ bool ConcurrentTask::abort()
QMutableHashIterator<Task*, Task::Ptr> doing_iter(m_doing);
while (doing_iter.hasNext()) {
auto task = doing_iter.next();
+ disconnect(task->get(), &Task::aborted, this, 0);
suceedeed &= (task.value())->abort();
}
@@ -130,6 +131,7 @@ void ConcurrentTask::startNext()
connect(next.get(), &Task::succeeded, this, [this, next]() { subTaskSucceeded(next); });
connect(next.get(), &Task::failed, this, [this, next](QString msg) { subTaskFailed(next, msg); });
+ connect(next.get(), &Task::aborted, this, [this, next] { subTaskFailed(next, "Aborted"); });
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); });
@@ -171,7 +173,7 @@ void ConcurrentTask::subTaskSucceeded(Task::Ptr task)
startNext();
}
-void ConcurrentTask::subTaskFailed(Task::Ptr task, const QString& msg)
+void ConcurrentTask::subTaskFailed(Task::Ptr task, [[maybe_unused]] const QString& msg)
{
m_done.insert(task.get(), task);
m_failed.insert(task.get(), task);
@@ -194,7 +196,7 @@ void ConcurrentTask::subTaskStatus(Task::Ptr task, const QString& msg)
auto task_progress = m_task_progress.value(task->getUid());
task_progress->status = msg;
task_progress->state = TaskStepState::Running;
-
+
emit stepProgress(*task_progress);
if (totalSize() == 1) {
@@ -207,7 +209,7 @@ void ConcurrentTask::subTaskDetails(Task::Ptr task, const QString& msg)
auto task_progress = m_task_progress.value(task->getUid());
task_progress->details = msg;
task_progress->state = TaskStepState::Running;
-
+
emit stepProgress(*task_progress);
if (totalSize() == 1) {
@@ -220,7 +222,7 @@ void ConcurrentTask::subTaskProgress(Task::Ptr task, qint64 current, qint64 tota
auto task_progress = m_task_progress.value(task->getUid());
task_progress->update(current, total);
-
+
emit stepProgress(*task_progress);
updateStepProgress(*task_progress, Operation::CHANGED);
updateState();
@@ -233,7 +235,7 @@ void ConcurrentTask::subTaskProgress(Task::Ptr task, qint64 current, qint64 tota
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;
@@ -254,12 +256,10 @@ void ConcurrentTask::subTaskStepProgress(Task::Ptr task, TaskStepProgress const&
emit stepProgress(*tp.get());
updateStepProgress(*tp.get(), op);
}
-
}
void ConcurrentTask::updateStepProgress(TaskStepProgress const& changed_progress, Operation op)
{
-
switch (op) {
case Operation::ADDED:
m_stepProgress += changed_progress.current;
@@ -274,9 +274,8 @@ void ConcurrentTask::updateStepProgress(TaskStepProgress const& changed_progress
m_stepTotalProgress -= changed_progress.old_total;
m_stepProgress += changed_progress.current;
m_stepTotalProgress += changed_progress.total;
- break;
+ break;
}
-
}
void ConcurrentTask::updateState()