kdeui: unregister any registered jobs from KPlasmaJobTracker destructor

this is so that jobs are not left in the plasma applets as active when, for
example, the program that has jobs registered is interrupted by a signal
(be that ctrl+c or something nasty like SIGSEGV). KUiServerJobTracker
was just warning about it but I can do better

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-05-01 06:47:51 +03:00
parent 77d32f4169
commit aeef583555

View file

@ -81,6 +81,18 @@ KPlasmaJobTracker::KPlasmaJobTracker(QObject *parent)
KPlasmaJobTracker::~KPlasmaJobTracker()
{
const int registeredjobs = d->jobs.size();
if (registeredjobs > 0) {
// force-unregister any jobs in applets otherwise the interface for the jobs becomes
// non-operational (there would be no jobs to stop anyway, this is the proxy to do it too)
kWarning() << "there are" << registeredjobs << "registered jobs still";
QMutableMapIterator<KJob*, QVariantMap> iter(d->jobs);
while (iter.hasNext()) {
iter.next();
unregisterJob(iter.key());
iter.remove();
}
}
delete d;
}