| 68 | } |
| 69 | |
| 70 | bool ConcurrentTask::abort() |
| 71 | { |
| 72 | m_queue.clear(); |
| 73 | |
| 74 | if (m_doing.isEmpty()) { |
| 75 | // Don't call emitAborted() here, we want to bypass the 'is the task running' check |
| 76 | emit aborted(); |
| 77 | emit finished(); |
| 78 | |
| 79 | return true; |
| 80 | } |
| 81 | |
| 82 | bool suceedeed = true; |
| 83 | |
| 84 | QMutableHashIterator<Task*, Task::Ptr> doing_iter(m_doing); |
| 85 | while (doing_iter.hasNext()) { |
| 86 | auto task = doing_iter.next(); |
| 87 | disconnect(task->get(), &Task::aborted, this, 0); |
| 88 | suceedeed &= (task.value())->abort(); |
| 89 | } |
| 90 | |
| 91 | if (suceedeed) |
| 92 | emitAborted(); |
| 93 | else |
| 94 | emitFailed(tr("Failed to abort all running tasks.")); |
| 95 | |
| 96 | return suceedeed; |
| 97 | } |
| 98 | |
| 99 | void ConcurrentTask::clear() |
| 100 | { |