MCPcopy Create free account
hub / github.com/KDE/kdevelop / subjobFinished

Method subjobFinished

kdevplatform/util/kdevcoreaddons/ksequentialcompoundjob.cpp:88–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88void KSequentialCompoundJob::subjobFinished(KJob *job)
89{
90 Q_D(KSequentialCompoundJob);
91 if (d->m_killingSubjob || isFinished()) {
92 // doKill() will return true and this compound job will finish, or already finished
93 removeSubjob(job);
94 return;
95 }
96
97 Q_ASSERT(d->m_jobIndex < d->m_jobCount); // invariant
98 // Note: isCurrentlyRunningSubjob(job) must be checked before calling removeSubjob(job).
99 if (!d->isCurrentlyRunningSubjob(job)) {
100 qCDebug(UTIL) << "unstarted subjob finished:" << job;
101 removeSubjob(job);
102 return;
103 }
104
105 const bool registeredSubjob = removeSubjob(job);
106 Q_ASSERT(registeredSubjob); // because isCurrentlyRunningSubjob(job) returned true
107
108 Q_ASSERT(d->m_jobIndex >= 0); // because isCurrentlyRunningSubjob(job) returned true
109 const unsigned long totalPercent = 100.0 * (d->m_jobIndex + 1) / d->m_jobCount;
110 qCDebug(UTIL) << "subjob finished:" << job << "; total percent:" << totalPercent;
111 setPercent(totalPercent);
112
113 int error = job->error();
114 if (!error && d->m_killingFailed) {
115 error = KilledJobError;
116 }
117
118 // Abort if job is the subjob we failed to kill and in case of error.
119 const bool abort = d->m_killingFailed || (d->m_abortOnSubjobError && error);
120 if (abort) {
121 qCDebug(UTIL) << "aborting on subjob error:" << error << job->errorText();
122 }
123
124 // Finish in order to abort, or if all subjobs have finished. Propagate the last-run subjob's error.
125 if (abort || d->m_subjobs.empty()) {
126 setError(error);
127 setErrorText(job->errorText());
128 emitResult();
129 return;
130 }
131
132 qCDebug(UTIL) << "remaining subjobs:" << d->m_subjobs;
133 d->startNextSubjob();
134}
135
136bool KSequentialCompoundJob::addSubjob(KJob *job)
137{

Callers

nothing calls this directly

Calls 5

errorTextMethod · 0.80
emptyMethod · 0.80
startNextSubjobMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected