| 81 | } |
| 82 | |
| 83 | void MinecraftUpdate::next() |
| 84 | { |
| 85 | if(m_abort) |
| 86 | { |
| 87 | emitFailed(tr("Aborted by user.")); |
| 88 | return; |
| 89 | } |
| 90 | if(m_failed_out_of_order) |
| 91 | { |
| 92 | emitFailed(m_fail_reason); |
| 93 | return; |
| 94 | } |
| 95 | m_currentTask ++; |
| 96 | if(m_currentTask > 0) |
| 97 | { |
| 98 | auto task = m_tasks[m_currentTask - 1]; |
| 99 | disconnect(task.get(), &Task::succeeded, this, &MinecraftUpdate::subtaskSucceeded); |
| 100 | disconnect(task.get(), &Task::failed, this, &MinecraftUpdate::subtaskFailed); |
| 101 | disconnect(task.get(), &Task::aborted, this, &Task::abort); |
| 102 | disconnect(task.get(), &Task::progress, this, &MinecraftUpdate::progress); |
| 103 | disconnect(task.get(), &Task::status, this, &MinecraftUpdate::setStatus); |
| 104 | } |
| 105 | if(m_currentTask == m_tasks.size()) |
| 106 | { |
| 107 | emitSucceeded(); |
| 108 | return; |
| 109 | } |
| 110 | auto task = m_tasks[m_currentTask]; |
| 111 | // if the task is already finished by the time we look at it, skip it |
| 112 | if(task->isFinished()) |
| 113 | { |
| 114 | qCritical() << "MinecraftUpdate: Skipping finished subtask" << m_currentTask << ":" << task.get(); |
| 115 | next(); |
| 116 | } |
| 117 | connect(task.get(), &Task::succeeded, this, &MinecraftUpdate::subtaskSucceeded); |
| 118 | connect(task.get(), &Task::failed, this, &MinecraftUpdate::subtaskFailed); |
| 119 | connect(task.get(), &Task::aborted, this, &Task::abort); |
| 120 | connect(task.get(), &Task::progress, this, &MinecraftUpdate::progress); |
| 121 | connect(task.get(), &Task::status, this, &MinecraftUpdate::setStatus); |
| 122 | // if the task is already running, do not start it again |
| 123 | if(!task->isRunning()) |
| 124 | { |
| 125 | task->start(); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | void MinecraftUpdate::subtaskSucceeded() |
| 130 | { |
no test coverage detected