* @brief Executor::executeNext consumes executable tasks from the queue */
| 69 | * @brief Executor::executeNext consumes executable tasks from the queue |
| 70 | */ |
| 71 | void Executor::executeNext() { |
| 72 | if (!running) { |
| 73 | if (!m_execQueue.isEmpty()) { |
| 74 | const execQueueItem &i = m_execQueue.head(); |
| 75 | running = true; |
| 76 | if (!i.workingDir.isEmpty()) { |
| 77 | m_process.setWorkingDirectory(i.workingDir); |
| 78 | } |
| 79 | startProcess(i.app, i.args); |
| 80 | if (!i.input.isEmpty()) { |
| 81 | if (!m_process.waitForStarted(-1)) { |
| 82 | #ifdef QT_DEBUG |
| 83 | dbg() << "Process failed to start:" << i.id << " " << i.app; |
| 84 | #endif |
| 85 | m_process.closeWriteChannel(); |
| 86 | running = false; |
| 87 | m_execQueue.dequeue(); |
| 88 | executeNext(); |
| 89 | return; |
| 90 | } |
| 91 | QByteArray data = i.input.toUtf8(); |
| 92 | if (m_process.write(data) != data.length()) { |
| 93 | #ifdef QT_DEBUG |
| 94 | dbg() << "Not all data written to process:" << i.id << " " << i.app; |
| 95 | #endif |
| 96 | } |
| 97 | } |
| 98 | m_process.closeWriteChannel(); |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * @brief Executor::execute execute an app |
nothing calls this directly
no outgoing calls
no test coverage detected