Fixes for task abort logic (#5415)

This commit is contained in:
Alexandru Ionut Tripon 2026-04-17 13:59:42 +00:00 committed by GitHub
commit 49e9f96327
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View file

@ -18,7 +18,7 @@ bool InstanceCreationTask::abort()
return m_gameFilesTask->abort(); return m_gameFilesTask->abort();
} }
return true; return InstanceTask::abort();
} }
void InstanceCreationTask::executeTask() void InstanceCreationTask::executeTask()

View file

@ -100,13 +100,18 @@ auto NetJob::canAbort() const -> bool
auto NetJob::abort() -> bool auto NetJob::abort() -> bool
{ {
bool fullyAborted = true;
// fail all downloads on the queue // fail all downloads on the queue
for (auto task : m_queue) for (auto task : m_queue)
m_failed.insert(task.get(), task); m_failed.insert(task.get(), task);
m_queue.clear(); m_queue.clear();
if (m_doing.isEmpty()) {
// no downloads to abort, NetJob is not running
return true;
}
bool fullyAborted = true;
// abort active downloads // abort active downloads
auto toKill = m_doing.values(); auto toKill = m_doing.values();
for (auto part : toKill) { for (auto part : toKill) {

View file

@ -165,7 +165,7 @@ class Task : public QObject, public QRunnable {
//! used by external code to ask the task to abort //! used by external code to ask the task to abort
virtual bool abort() virtual bool abort()
{ {
if (canAbort()) if (canAbort() && isRunning())
emitAborted(); emitAborted();
return canAbort(); return canAbort();
} }