aboutsummaryrefslogtreecommitdiff
path: root/launcher/tasks
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-05-28 17:44:23 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-05-28 17:44:23 +0300
commit27c3775f99fd5b6fed08f316b304add8c9d1b106 (patch)
tree0406cfc149297f1c882cd8bf5d7e3d40246577ce /launcher/tasks
parentbf0a577fb9d063d90d0003227fce08f32fa09dd1 (diff)
parent954d4d701a136e79c25b58f9680d26a555a6e6fe (diff)
downloadPrismLauncher-27c3775f99fd5b6fed08f316b304add8c9d1b106.tar.gz
PrismLauncher-27c3775f99fd5b6fed08f316b304add8c9d1b106.tar.bz2
PrismLauncher-27c3775f99fd5b6fed08f316b304add8c9d1b106.zip
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into Fix_Assert
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/tasks')
-rw-r--r--launcher/tasks/ConcurrentTask.cpp27
-rw-r--r--launcher/tasks/Task.cpp2
-rw-r--r--launcher/tasks/Task.h14
3 files changed, 26 insertions, 17 deletions
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index fae2f3dc..5ee14505 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -138,7 +138,7 @@ void ConcurrentTask::startNext()
connect(next.get(), &Task::progress, this, [this, next](qint64 current, qint64 total) { subTaskProgress(next, current, total); });
m_doing.insert(next.get(), next);
- auto task_progress = std::make_shared<TaskStepProgress>(TaskStepProgress({ next->getUid() }));
+ auto task_progress = std::make_shared<TaskStepProgress>(next->getUid());
m_task_progress.insert(next->getUid(), task_progress);
updateState();
@@ -166,9 +166,9 @@ void ConcurrentTask::subTaskSucceeded(Task::Ptr task)
disconnect(task.get(), 0, this, 0);
- emit stepProgress(*task_progress.get());
+ emit stepProgress(*task_progress);
updateState();
- updateStepProgress(*task_progress.get(), Operation::REMOVED);
+ updateStepProgress(*task_progress, Operation::REMOVED);
startNext();
}
@@ -184,9 +184,9 @@ void ConcurrentTask::subTaskFailed(Task::Ptr task, const QString& msg)
disconnect(task.get(), 0, this, 0);
- emit stepProgress(*task_progress.get());
+ emit stepProgress(*task_progress);
updateState();
- updateStepProgress(*task_progress.get(), Operation::REMOVED);
+ updateStepProgress(*task_progress, Operation::REMOVED);
startNext();
}
@@ -196,7 +196,7 @@ void ConcurrentTask::subTaskStatus(Task::Ptr task, const QString& msg)
task_progress->status = msg;
task_progress->state = TaskStepState::Running;
- emit stepProgress(*task_progress.get());
+ emit stepProgress(*task_progress);
if (totalSize() == 1) {
setStatus(msg);
@@ -209,7 +209,7 @@ void ConcurrentTask::subTaskDetails(Task::Ptr task, const QString& msg)
task_progress->details = msg;
task_progress->state = TaskStepState::Running;
- emit stepProgress(*task_progress.get());
+ emit stepProgress(*task_progress);
if (totalSize() == 1) {
setDetails(msg);
@@ -220,15 +220,10 @@ void ConcurrentTask::subTaskProgress(Task::Ptr task, qint64 current, qint64 tota
{
auto task_progress = m_task_progress.value(task->getUid());
- task_progress->old_current = task_progress->current;
- task_progress->old_total = task_progress->old_total;
-
- task_progress->current = current;
- task_progress->total = total;
- task_progress->state = TaskStepState::Running;
-
- emit stepProgress(*task_progress.get());
- updateStepProgress(*task_progress.get(), Operation::CHANGED);
+ task_progress->update(current, total);
+
+ emit stepProgress(*task_progress);
+ updateStepProgress(*task_progress, Operation::CHANGED);
updateState();
if (totalSize() == 1) {
diff --git a/launcher/tasks/Task.cpp b/launcher/tasks/Task.cpp
index b0addd46..29c55cd4 100644
--- a/launcher/tasks/Task.cpp
+++ b/launcher/tasks/Task.cpp
@@ -109,7 +109,7 @@ void Task::start()
return;
}
}
- // NOTE: only fall thorugh to here in end states
+ // NOTE: only fall through to here in end states
m_state = State::Running;
emit started();
executeTask();
diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h
index 799ed945..6d8bbbb4 100644
--- a/launcher/tasks/Task.h
+++ b/launcher/tasks/Task.h
@@ -64,7 +64,21 @@ struct TaskStepProgress {
QString status = "";
QString details = "";
TaskStepState state = TaskStepState::Waiting;
+ TaskStepProgress() {
+ this->uid = QUuid::createUuid();
+ }
+ TaskStepProgress(QUuid uid) {
+ this->uid = uid;
+ }
bool isDone() const { return (state == TaskStepState::Failed) || (state == TaskStepState::Succeeded); }
+ void update(qint64 current, qint64 total) {
+ this->old_current = this->current;
+ this->old_total = this->total;
+
+ this->current = current;
+ this->total = total;
+ this->state = TaskStepState::Running;
+ }
};
Q_DECLARE_METATYPE(TaskStepProgress)