From 8c300316350f76fee21c9e9fd20a54fc4ecf56f4 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Thu, 12 Mar 2009 22:01:22 +0000 Subject: [PATCH] * let the weaver own the jobs, so we can cean up successfully without crashing when the manager is deleted * listen to jobDone's in the clean up class svn path=/trunk/KDE/kdelibs/; revision=938752 --- private/runnerjobs.cpp | 16 ++++++++++++++++ runnermanager.cpp | 15 ++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/private/runnerjobs.cpp b/private/runnerjobs.cpp index 87eb7a22f..a9daa0b40 100644 --- a/private/runnerjobs.cpp +++ b/private/runnerjobs.cpp @@ -173,6 +173,22 @@ DelayedJobCleaner::DelayedJobCleaner(QSet jobs, ThreadWeaver::W m_jobs(jobs) { connect(m_weaver, SIGNAL(finished()), this, SLOT(checkIfFinished())); + + foreach (FindMatchesJob *job, m_jobs) { + connect(job, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(jobDone(ThreadWeaver::Job*))); + } +} + +void DelayedJobCleaner::jobDone(ThreadWeaver::Job *job) +{ + FindMatchesJob *runJob = dynamic_cast(job); + + if (!runJob) { + return; + } + + m_jobs.remove(runJob); + delete runJob; } void DelayedJobCleaner::checkIfFinished() diff --git a/runnermanager.cpp b/runnermanager.cpp index d96e219d5..e019516af 100644 --- a/runnermanager.cpp +++ b/runnermanager.cpp @@ -160,7 +160,7 @@ public: void jobDone(ThreadWeaver::Job *job) { - FindMatchesJob *runJob = dynamic_cast(job); + FindMatchesJob *runJob = dynamic_cast(job); if (!runJob) { return; @@ -194,17 +194,6 @@ public: QObject::connect(dummy, SIGNAL(done(ThreadWeaver::Job*)), dummy, SLOT(deleteLater())); } - void checkIfFinished() - { - if (Weaver::instance()->isIdle()) { - qDeleteAll(searchJobs); - searchJobs.clear(); - qDeleteAll(oldSearchJobs); - oldSearchJobs.clear(); - q->deleteLater(); - } - } - // Delay in ms before slow runners are allowed to run static const int slowRunDelay = 400; @@ -358,7 +347,7 @@ void RunnerManager::launchQuery(const QString &term, const QString &runnerName) foreach (Plasma::AbstractRunner *r, runable) { if ((r->ignoredTypes() & d->context.type()) == 0) { // kDebug() << "launching" << r->name(); - FindMatchesJob *job = new FindMatchesJob(r, &d->context, this); + FindMatchesJob *job = new FindMatchesJob(r, &d->context, Weaver::instance()); connect(job, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(jobDone(ThreadWeaver::Job*))); if (r->speed() == AbstractRunner::SlowSpeed) { job->setDelayTimer(&d->delayTimer);