| 606 | } |
| 607 | |
| 608 | void KDevelop::RunController::registerJob(KJob * job) |
| 609 | { |
| 610 | Q_D(RunController); |
| 611 | |
| 612 | if (!job) |
| 613 | return; |
| 614 | |
| 615 | if (!(job->capabilities() & KJob::Killable)) { |
| 616 | // see e.g. https://bugs.kde.org/show_bug.cgi?id=314187 |
| 617 | qCWarning(SHELL) << "non-killable job" << job << "registered - this might lead to crashes on shutdown."; |
| 618 | } |
| 619 | |
| 620 | if (!d->jobs.contains(job)) { |
| 621 | QAction* stopJobAction = nullptr; |
| 622 | if (Core::self()->setupFlags() != Core::NoUi) { |
| 623 | stopJobAction = new QAction(job->objectName().isEmpty() ? i18nc("@item:inmenu", "<%1> Unnamed job", QString::fromUtf8(job->staticMetaObject.className())) : job->objectName(), this); |
| 624 | stopJobAction->setData(QVariant::fromValue(static_cast<void*>(job))); |
| 625 | d->stopJobsMenu->addAction(stopJobAction); |
| 626 | connect (stopJobAction, &QAction::triggered, this, &RunController::slotKillJob); |
| 627 | |
| 628 | job->setUiDelegate( new KDialogJobUiDelegate() ); |
| 629 | } |
| 630 | |
| 631 | d->jobs.insert(job, stopJobAction); |
| 632 | |
| 633 | connect( job, &KJob::finished, this, &RunController::finished ); |
| 634 | connect(job, &KJob::percentChanged, this, &RunController::jobPercentChanged); |
| 635 | |
| 636 | IRunController::registerJob(job); |
| 637 | |
| 638 | emit jobRegistered(job); |
| 639 | } |
| 640 | |
| 641 | const QPointer thisGuard(this); |
| 642 | job->start(); |
| 643 | if (!thisGuard) { |
| 644 | return; // already destroyed (KDevelop is probably exiting now) |
| 645 | } |
| 646 | |
| 647 | checkState(); |
| 648 | } |
| 649 | |
| 650 | void KDevelop::RunController::unregisterJob(KJob * job) |
| 651 | { |