| 310 | } |
| 311 | |
| 312 | bool QmitkPipInstallDialog::ConfirmCancel() |
| 313 | { |
| 314 | auto answer = QMessageBox::question( |
| 315 | this, |
| 316 | "Cancel installation", |
| 317 | "<p>The installation is still in progress. " |
| 318 | "Closing now will cancel the installation and remove all already installed packages.</p>" |
| 319 | "<p>Cancel anyway?</p>"); |
| 320 | |
| 321 | if (answer == QMessageBox::No) |
| 322 | return false; |
| 323 | |
| 324 | m_IsCancelling = true; |
| 325 | |
| 326 | // Show that a cancel is in progress and prevent further interaction while |
| 327 | // pip is being killed and the venv torn down. |
| 328 | m_DotTimer->stop(); |
| 329 | this->SetTerminalStatus("Cancelling installation..."); |
| 330 | m_Ui->packageLabel->hide(); |
| 331 | m_Ui->progressBar->hide(); |
| 332 | m_Ui->buttonBox->setEnabled(false); |
| 333 | |
| 334 | // Spin a local event loop so the dialog stays alive until FinalizeCancel |
| 335 | // has run (it removes the venv that we created) and emits InstallFinished. |
| 336 | // Without this, the dialog would close as soon as ConfirmCancel returned |
| 337 | // and the engine would be destroyed before OnProcessFinished could fire. |
| 338 | // |
| 339 | // Safety cap: if the pip kill or the venv removal wedges (AV holding files |
| 340 | // open, zombie subprocess on Windows, etc.), quit the loop after 30 s so |
| 341 | // the dialog can close instead of locking forever. A legitimate |
| 342 | // fs::remove_all is comfortably inside that envelope even on a slow disk. |
| 343 | // Queued connection so the synchronous Cancel() path (no QProcess running) |
| 344 | // that emits InstallFinished directly from inside Cancel() still reaches |
| 345 | // the loop: the queued slot is posted as an event and delivered once |
| 346 | // loop.exec() starts spinning. |
| 347 | QEventLoop loop; |
| 348 | connect(m_Installer, &QmitkPipInstaller::InstallFinished, &loop, &QEventLoop::quit, Qt::QueuedConnection); |
| 349 | QTimer::singleShot(30000, &loop, &QEventLoop::quit); |
| 350 | m_Installer->Cancel(); |
| 351 | loop.exec(); |
| 352 | |
| 353 | return true; |
| 354 | } |
| 355 | |
| 356 | void QmitkPipInstallDialog::SetUiInstalling() |
| 357 | { |
no test coverage detected