| 45 | } |
| 46 | |
| 47 | bool ConcurrentTask::abort() |
| 48 | { |
| 49 | m_queue.clear(); |
| 50 | m_aborted = true; |
| 51 | |
| 52 | if (m_doing.isEmpty()) { |
| 53 | // Don't call emitAborted() here, we want to bypass the 'is the task running' check |
| 54 | emit aborted(); |
| 55 | emit finished(); |
| 56 | |
| 57 | return true; |
| 58 | } |
| 59 | |
| 60 | bool suceedeed = true; |
| 61 | |
| 62 | QMutableHashIterator<Task*, Task::Ptr> doing_iter(m_doing); |
| 63 | while (doing_iter.hasNext()) { |
| 64 | auto task = doing_iter.next(); |
| 65 | suceedeed &= (task.value())->abort(); |
| 66 | } |
| 67 | |
| 68 | if (suceedeed) |
| 69 | emitAborted(); |
| 70 | else |
| 71 | emitFailed(tr("Failed to abort all running tasks.")); |
| 72 | |
| 73 | return suceedeed; |
| 74 | } |
| 75 | |
| 76 | void ConcurrentTask::startNext() |
| 77 | { |