| 74 | } |
| 75 | |
| 76 | void ConcurrentTask::startNext() |
| 77 | { |
| 78 | if (m_aborted || m_doing.count() > m_total_max_size) |
| 79 | return; |
| 80 | |
| 81 | if (m_queue.isEmpty() && m_doing.isEmpty() && !wasSuccessful()) { |
| 82 | emitSucceeded(); |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | if (m_queue.isEmpty()) |
| 87 | return; |
| 88 | |
| 89 | Task::Ptr next = m_queue.dequeue(); |
| 90 | |
| 91 | connect(next.get(), &Task::succeeded, this, [this, next] { subTaskSucceeded(next); }); |
| 92 | connect(next.get(), &Task::failed, this, [this, next](QString msg) { subTaskFailed(next, msg); }); |
| 93 | |
| 94 | connect(next.get(), &Task::status, this, &ConcurrentTask::subTaskStatus); |
| 95 | connect(next.get(), &Task::stepStatus, this, &ConcurrentTask::subTaskStatus); |
| 96 | |
| 97 | connect(next.get(), &Task::progress, this, &ConcurrentTask::subTaskProgress); |
| 98 | |
| 99 | m_doing.insert(next.get(), next); |
| 100 | |
| 101 | setStepStatus(next->isMultiStep() ? next->getStepStatus() : next->getStatus()); |
| 102 | updateState(); |
| 103 | |
| 104 | QMetaObject::invokeMethod( |
| 105 | this, [=] { next->start(); }, Qt::QueuedConnection); |
| 106 | } |
| 107 | |
| 108 | void ConcurrentTask::subTaskSucceeded(Task::Ptr task) |
| 109 | { |
nothing calls this directly
no test coverage detected