* emit a signal when our jobs are done but we have no matches
* use QSets instead of QLists where we are doing lots of random access and no sequential * get rid of the stale marking as all items in the oldMatches list are, by definition, stale svn path=/trunk/KDE/kdelibs/; revision=938708
This commit is contained in:
parent
0f57196266
commit
592ddc4e6e
@ -127,8 +127,7 @@ FindMatchesJob::FindMatchesJob(Plasma::AbstractRunner *runner,
|
||||
: ThreadWeaver::Job(parent),
|
||||
m_context(*context, 0),
|
||||
m_runner(runner),
|
||||
m_timer(0),
|
||||
m_stale(false)
|
||||
m_timer(0)
|
||||
{
|
||||
if (runner->speed() == Plasma::AbstractRunner::SlowSpeed) {
|
||||
assignQueuePolicy(&DelayedRunnerPolicy::instance());
|
||||
|
@ -107,9 +107,6 @@ public:
|
||||
|
||||
int priority() const;
|
||||
Plasma::AbstractRunner* runner() const;
|
||||
void setStale();
|
||||
bool isStale() const;
|
||||
|
||||
|
||||
QTimer* delayTimer() const;
|
||||
void setDelayTimer(QTimer *timer);
|
||||
@ -121,7 +118,6 @@ private:
|
||||
Plasma::RunnerContext m_context;
|
||||
Plasma::AbstractRunner *m_runner;
|
||||
QTimer *m_timer;
|
||||
bool m_stale;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -167,8 +167,17 @@ public:
|
||||
deferredRun = QueryMatch(0);
|
||||
tmpRun.run(context);
|
||||
}
|
||||
searchJobs.removeAll(runJob);
|
||||
|
||||
searchJobs.remove(runJob);
|
||||
oldSearchJobs.remove(runJob);
|
||||
delete runJob;
|
||||
|
||||
if (searchJobs.isEmpty() && context.matches().isEmpty()) {
|
||||
// we finished our run, and there are no valid matches, and so no
|
||||
// signal will have been sent out. so we need to emit the signal
|
||||
// ourselves here
|
||||
emit q->matchesChanged(context.matches());
|
||||
}
|
||||
}
|
||||
|
||||
void unblockJobs()
|
||||
@ -189,21 +198,12 @@ public:
|
||||
QTimer matchChangeTimer;
|
||||
QTimer delayTimer; // Timer to control when to run slow runners
|
||||
QHash<QString, AbstractRunner*> runners;
|
||||
QList<FindMatchesJob*> searchJobs;
|
||||
QSet<FindMatchesJob*> searchJobs;
|
||||
QSet<FindMatchesJob*> oldSearchJobs;
|
||||
bool loadAll;
|
||||
KConfigGroup config;
|
||||
};
|
||||
|
||||
void FindMatchesJob::setStale()
|
||||
{
|
||||
m_stale = true;
|
||||
}
|
||||
|
||||
bool FindMatchesJob::isStale() const
|
||||
{
|
||||
return m_stale;
|
||||
}
|
||||
|
||||
/*****************************************************
|
||||
* RunnerManager::Public class
|
||||
*
|
||||
@ -274,8 +274,8 @@ void RunnerManager::run(const QueryMatch &match)
|
||||
AbstractRunner *runner = match.runner();
|
||||
|
||||
foreach (FindMatchesJob *job, d->searchJobs) {
|
||||
if (job->runner() == runner && !job->isFinished() && !job->isStale()) {
|
||||
kDebug() << "!!!!!!!!!!!!!!!!!!! uh oh!";
|
||||
if (job->runner() == runner && !job->isFinished()) {
|
||||
kDebug() << "deferred run";
|
||||
d->deferredRun = match;
|
||||
return;
|
||||
}
|
||||
@ -286,9 +286,6 @@ void RunnerManager::run(const QueryMatch &match)
|
||||
}
|
||||
|
||||
match.run(d->context);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
QList<QAction*> RunnerManager::actionsForMatch(const QueryMatch &match)
|
||||
@ -347,7 +344,7 @@ void RunnerManager::launchQuery(const QString &term, const QString &runnerName)
|
||||
job->setDelayTimer(&d->delayTimer);
|
||||
}
|
||||
Weaver::instance()->enqueue(job);
|
||||
d->searchJobs.append(job);
|
||||
d->searchJobs.insert(job);
|
||||
}
|
||||
}
|
||||
// Start timer to unblock slow runners
|
||||
@ -407,16 +404,14 @@ void RunnerManager::reset()
|
||||
// If ThreadWeaver is idle, it is safe to clear previous jobs
|
||||
if (Weaver::instance()->isIdle()) {
|
||||
qDeleteAll(d->searchJobs);
|
||||
d->searchJobs.clear();
|
||||
qDeleteAll(d->oldSearchJobs);
|
||||
} else {
|
||||
Weaver::instance()->dequeue();
|
||||
// Since we cannot safely delete the jobs, mark them as stale
|
||||
// TODO: delete them eventually?
|
||||
foreach (FindMatchesJob *job, d->searchJobs) {
|
||||
job->setStale();
|
||||
}
|
||||
d->oldSearchJobs += d->searchJobs;
|
||||
}
|
||||
|
||||
d->searchJobs.clear();
|
||||
|
||||
if (d->deferredRun.isEnabled()) {
|
||||
//kDebug() << "job actually done, running now **************";
|
||||
QueryMatch tmpRun = d->deferredRun;
|
||||
|
Loading…
Reference in New Issue
Block a user