| 228 | } |
| 229 | |
| 230 | void QmitkPipInstaller::OnProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) |
| 231 | { |
| 232 | // Cancellation: the process was killed by Cancel(). Run cleanup and emit the |
| 233 | // terminal signal here, off the original Cancel() call stack, so the UI |
| 234 | // thread is not blocked while we tear down the venv. |
| 235 | if (m_State == State::Cancelling) |
| 236 | { |
| 237 | this->FinalizeCancel(); |
| 238 | return; |
| 239 | } |
| 240 | |
| 241 | bool success = exitStatus == QProcess::NormalExit && exitCode == 0; |
| 242 | auto numPackages = static_cast<int>(m_ResolvedPackages.size()); |
| 243 | |
| 244 | switch (m_State) |
| 245 | { |
| 246 | case State::CreatingVirtualEnv: |
| 247 | { |
| 248 | if (!success) |
| 249 | { |
| 250 | m_State = State::Failed; |
| 251 | emit ErrorOccurred("Failed to create virtual environment."); |
| 252 | emit InstallFinished(false); |
| 253 | return; |
| 254 | } |
| 255 | |
| 256 | if (!mitk::PythonHelper::ActivateVirtualEnv(m_Spec.venvName)) |
| 257 | { |
| 258 | m_State = State::Failed; |
| 259 | emit ErrorOccurred("Failed to activate virtual environment."); |
| 260 | emit InstallFinished(false); |
| 261 | return; |
| 262 | } |
| 263 | |
| 264 | if (m_Spec.upgradePipFirst) |
| 265 | { |
| 266 | this->StartPipUpgrade(); |
| 267 | } |
| 268 | else |
| 269 | { |
| 270 | emit ResolveStarted(); |
| 271 | this->StartResolveGroup(); |
| 272 | } |
| 273 | break; |
| 274 | } |
| 275 | |
| 276 | case State::UpgradingPip: |
| 277 | { |
| 278 | // pip upgrade failure is non-fatal - proceed to resolve first group. |
| 279 | m_State = State::Resolving; |
| 280 | emit ResolveStarted(); |
| 281 | this->StartResolveGroup(); |
| 282 | break; |
| 283 | } |
| 284 | |
| 285 | case State::Resolving: |
| 286 | { |
| 287 | if (!success) |
nothing calls this directly
no test coverage detected