fix: abort logic running subsequent tasks anyways some times
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
c410bb4ecb
commit
bdf464e792
@ -45,25 +45,31 @@ void ConcurrentTask::executeTask()
|
||||
|
||||
bool ConcurrentTask::abort()
|
||||
{
|
||||
m_queue.clear();
|
||||
m_aborted = true;
|
||||
|
||||
if (m_doing.isEmpty()) {
|
||||
// Don't call emitAborted() here, we want to bypass the 'is the task running' check
|
||||
emit aborted();
|
||||
emit finished();
|
||||
|
||||
m_aborted = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_queue.clear();
|
||||
bool suceedeed = true;
|
||||
|
||||
m_aborted = true;
|
||||
for (auto task : m_doing)
|
||||
m_aborted &= task->abort();
|
||||
QMutableHashIterator<Task*, Task::Ptr> doing_iter(m_doing);
|
||||
while (doing_iter.hasNext()) {
|
||||
auto task = doing_iter.next();
|
||||
suceedeed &= (task.value())->abort();
|
||||
}
|
||||
|
||||
if (m_aborted)
|
||||
if (suceedeed)
|
||||
emitAborted();
|
||||
else
|
||||
emitFailed(tr("Failed to abort all running tasks."));
|
||||
|
||||
return m_aborted;
|
||||
return suceedeed;
|
||||
}
|
||||
|
||||
void ConcurrentTask::startNext()
|
||||
|
@ -9,7 +9,9 @@ class ConcurrentTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConcurrentTask(QObject* parent = nullptr, QString task_name = "", int max_concurrent = 6);
|
||||
virtual ~ConcurrentTask();
|
||||
~ConcurrentTask() override;
|
||||
|
||||
bool canAbort() const override { return true; }
|
||||
|
||||
inline auto isMultiStep() const -> bool override { return m_queue.size() > 1; };
|
||||
auto getStepProgress() const -> qint64 override;
|
||||
|
Loading…
Reference in New Issue
Block a user