fix: crash when task was canceled and abort signal was fired early (#3712)

This commit is contained in:
Alexandru Ionut Tripon 2025-04-30 10:10:36 +03:00 committed by GitHub
commit 36d18b393b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 6 deletions

View File

@ -72,7 +72,6 @@ bool InstanceImportTask::abort()
bool wasAborted = false;
if (m_task)
wasAborted = m_task->abort();
Task::abort();
return wasAborted;
}
@ -305,7 +304,7 @@ void InstanceImportTask::processFlame()
connect(inst_creation_task.get(), &Task::status, this, &InstanceImportTask::setStatus);
connect(inst_creation_task.get(), &Task::details, this, &InstanceImportTask::setDetails);
connect(inst_creation_task.get(), &Task::aborted, this, &Task::abort);
connect(inst_creation_task.get(), &Task::aborted, this, &InstanceImportTask::emitAborted);
connect(inst_creation_task.get(), &Task::abortStatusChanged, this, &Task::setAbortable);
m_task.reset(inst_creation_task);
@ -404,7 +403,7 @@ void InstanceImportTask::processModrinth()
connect(inst_creation_task.get(), &Task::status, this, &InstanceImportTask::setStatus);
connect(inst_creation_task.get(), &Task::details, this, &InstanceImportTask::setDetails);
connect(inst_creation_task.get(), &Task::aborted, this, &Task::abort);
connect(inst_creation_task.get(), &Task::aborted, this, &InstanceImportTask::emitAborted);
connect(inst_creation_task.get(), &Task::abortStatusChanged, this, &Task::setAbortable);
m_task.reset(inst_creation_task);

View File

@ -55,6 +55,7 @@ void ArchiveDownloadTask::executeTask()
connect(download.get(), &Task::stepProgress, this, &ArchiveDownloadTask::propagateStepProgress);
connect(download.get(), &Task::status, this, &ArchiveDownloadTask::setStatus);
connect(download.get(), &Task::details, this, &ArchiveDownloadTask::setDetails);
connect(download.get(), &Task::aborted, this, &ArchiveDownloadTask::emitAborted);
connect(download.get(), &Task::succeeded, [this, fullPath] {
// This should do all of the extracting and creating folders
extractJava(fullPath);
@ -135,7 +136,6 @@ bool ArchiveDownloadTask::abort()
auto aborted = canAbort();
if (m_task)
aborted = m_task->abort();
emitAborted();
return aborted;
};
} // namespace Java

View File

@ -70,7 +70,6 @@ bool FlamePackExportTask::abort()
{
if (task) {
task->abort();
emitAborted();
return true;
}
return false;
@ -171,6 +170,7 @@ void FlamePackExportTask::collectHashes()
progressStep->status = status;
stepProgress(*progressStep);
});
connect(hashingTask.get(), &Task::aborted, this, &FlamePackExportTask::emitAborted);
hashingTask->start();
}
@ -246,6 +246,7 @@ void FlamePackExportTask::makeApiRequest()
getProjectsInfo();
});
connect(task.get(), &Task::failed, this, &FlamePackExportTask::getProjectsInfo);
connect(task.get(), &Task::aborted, this, &FlamePackExportTask::emitAborted);
task->start();
}
@ -324,6 +325,7 @@ void FlamePackExportTask::getProjectsInfo()
buildZip();
});
connect(projTask.get(), &Task::failed, this, &FlamePackExportTask::emitFailed);
connect(task.get(), &Task::aborted, this, &FlamePackExportTask::emitAborted);
task.reset(projTask);
task->start();
}

View File

@ -63,7 +63,6 @@ bool ModrinthPackExportTask::abort()
{
if (task) {
task->abort();
emitAborted();
return true;
}
return false;
@ -158,6 +157,7 @@ void ModrinthPackExportTask::makeApiRequest()
task = api.currentVersions(pendingHashes.values(), "sha512", response);
connect(task.get(), &Task::succeeded, [this, response]() { parseApiResponse(response); });
connect(task.get(), &Task::failed, this, &ModrinthPackExportTask::emitFailed);
connect(task.get(), &Task::aborted, this, &ModrinthPackExportTask::emitAborted);
task->start();
}
}