mirror of
https://github.com/PrismLauncher/PrismLauncher
synced 2026-04-23 09:05:03 +00:00
fix(ComponentUpdateTask): allow aborting
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
2338455076
commit
f007d90076
|
|
@ -59,9 +59,7 @@ bool TaskStepWrapper::canAbort() const
|
|||
bool TaskStepWrapper::abort()
|
||||
{
|
||||
if (m_task && m_task->canAbort()) {
|
||||
auto status = m_task->abort();
|
||||
emitFailed("Aborted.");
|
||||
return status;
|
||||
return m_task->abort();
|
||||
}
|
||||
return Task::abort();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@
|
|||
* If the component list changes, start over.
|
||||
*/
|
||||
|
||||
/*
|
||||
* TODO: This task launches multiple other tasks. As such it should be converted to a ConcurrentTask
|
||||
*/
|
||||
ComponentUpdateTask::ComponentUpdateTask(Mode mode, Net::Mode netmode, PackProfile* list) : Task()
|
||||
{
|
||||
d.reset(new ComponentUpdateTaskData);
|
||||
|
|
@ -48,6 +51,29 @@ ComponentUpdateTask::ComponentUpdateTask(Mode mode, Net::Mode netmode, PackProfi
|
|||
|
||||
ComponentUpdateTask::~ComponentUpdateTask() {}
|
||||
|
||||
bool ComponentUpdateTask::canAbort() const
|
||||
{
|
||||
for (const auto& status : d->remoteLoadStatusList) {
|
||||
if (status.task && !status.task->canAbort()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ComponentUpdateTask::abort()
|
||||
{
|
||||
bool aborted = true;
|
||||
for (const auto& status : d->remoteLoadStatusList) {
|
||||
if (status.task && !status.task->abort()) {
|
||||
aborted = false;
|
||||
}
|
||||
}
|
||||
|
||||
return aborted;
|
||||
}
|
||||
|
||||
void ComponentUpdateTask::executeTask()
|
||||
{
|
||||
qCDebug(instanceProfileResolveC) << "Loading components";
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ class ComponentUpdateTask : public Task {
|
|||
explicit ComponentUpdateTask(Mode mode, Net::Mode netmode, PackProfile* list);
|
||||
virtual ~ComponentUpdateTask();
|
||||
|
||||
bool canAbort() const override;
|
||||
bool abort() override;
|
||||
|
||||
protected:
|
||||
void executeTask();
|
||||
|
||||
|
|
|
|||
|
|
@ -38,9 +38,7 @@ bool MinecraftLoadAndCheck::canAbort() const
|
|||
bool MinecraftLoadAndCheck::abort()
|
||||
{
|
||||
if (m_task && m_task->canAbort()) {
|
||||
auto status = m_task->abort();
|
||||
emitFailed("Aborted.");
|
||||
return status;
|
||||
return m_task->abort();
|
||||
}
|
||||
return Task::abort();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue