aboutsummaryrefslogtreecommitdiff
path: root/launcher/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/tasks')
-rw-r--r--launcher/tasks/ConcurrentTask.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index bc3cf4d3..8f688f07 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -27,10 +27,8 @@ auto ConcurrentTask::getStepTotalProgress() const -> qint64
void ConcurrentTask::addTask(Task::Ptr task)
{
- if (!isRunning())
- m_queue.append(task);
- else
- qWarning() << "Tried to add a task to a running concurrent task!";
+ m_queue.append(task);
+ m_total_size += 1;
}
void ConcurrentTask::executeTask()
@@ -117,9 +115,14 @@ void ConcurrentTask::startNext()
setStepStatus(next->isMultiStep() ? next->getStepStatus() : next->getStatus());
updateState();
- QCoreApplication::processEvents();
+ QMetaObject::invokeMethod(next.get(), &Task::start, Qt::QueuedConnection);
- next->start();
+ // Allow going up the number of concurrent tasks in case of tasks being added in the middle of a running task.
+ int num_starts = m_total_max_size - m_doing.size();
+ for (int i = 0; i < num_starts; i++)
+ QMetaObject::invokeMethod(this, &ConcurrentTask::startNext, Qt::QueuedConnection);
+
+ QCoreApplication::processEvents();
}
void ConcurrentTask::subTaskSucceeded(Task::Ptr task)