* 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
This commit is contained in:
Aaron J. Seigo 2009-03-12 22:01:22 +00:00
parent 3ecfa9f6d5
commit 8c30031635
2 changed files with 18 additions and 13 deletions

View File

@ -173,6 +173,22 @@ DelayedJobCleaner::DelayedJobCleaner(QSet<FindMatchesJob*> 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<FindMatchesJob *>(job);
if (!runJob) {
return;
}
m_jobs.remove(runJob);
delete runJob;
}
void DelayedJobCleaner::checkIfFinished()

View File

@ -160,7 +160,7 @@ public:
void jobDone(ThreadWeaver::Job *job)
{
FindMatchesJob *runJob = dynamic_cast<FindMatchesJob*>(job);
FindMatchesJob *runJob = dynamic_cast<FindMatchesJob *>(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);