* 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),
|
: ThreadWeaver::Job(parent),
|
||||||
m_context(*context, 0),
|
m_context(*context, 0),
|
||||||
m_runner(runner),
|
m_runner(runner),
|
||||||
m_timer(0),
|
m_timer(0)
|
||||||
m_stale(false)
|
|
||||||
{
|
{
|
||||||
if (runner->speed() == Plasma::AbstractRunner::SlowSpeed) {
|
if (runner->speed() == Plasma::AbstractRunner::SlowSpeed) {
|
||||||
assignQueuePolicy(&DelayedRunnerPolicy::instance());
|
assignQueuePolicy(&DelayedRunnerPolicy::instance());
|
||||||
|
@ -107,9 +107,6 @@ public:
|
|||||||
|
|
||||||
int priority() const;
|
int priority() const;
|
||||||
Plasma::AbstractRunner* runner() const;
|
Plasma::AbstractRunner* runner() const;
|
||||||
void setStale();
|
|
||||||
bool isStale() const;
|
|
||||||
|
|
||||||
|
|
||||||
QTimer* delayTimer() const;
|
QTimer* delayTimer() const;
|
||||||
void setDelayTimer(QTimer *timer);
|
void setDelayTimer(QTimer *timer);
|
||||||
@ -121,7 +118,6 @@ private:
|
|||||||
Plasma::RunnerContext m_context;
|
Plasma::RunnerContext m_context;
|
||||||
Plasma::AbstractRunner *m_runner;
|
Plasma::AbstractRunner *m_runner;
|
||||||
QTimer *m_timer;
|
QTimer *m_timer;
|
||||||
bool m_stale;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -167,8 +167,17 @@ public:
|
|||||||
deferredRun = QueryMatch(0);
|
deferredRun = QueryMatch(0);
|
||||||
tmpRun.run(context);
|
tmpRun.run(context);
|
||||||
}
|
}
|
||||||
searchJobs.removeAll(runJob);
|
|
||||||
|
searchJobs.remove(runJob);
|
||||||
|
oldSearchJobs.remove(runJob);
|
||||||
delete 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()
|
void unblockJobs()
|
||||||
@ -189,21 +198,12 @@ public:
|
|||||||
QTimer matchChangeTimer;
|
QTimer matchChangeTimer;
|
||||||
QTimer delayTimer; // Timer to control when to run slow runners
|
QTimer delayTimer; // Timer to control when to run slow runners
|
||||||
QHash<QString, AbstractRunner*> runners;
|
QHash<QString, AbstractRunner*> runners;
|
||||||
QList<FindMatchesJob*> searchJobs;
|
QSet<FindMatchesJob*> searchJobs;
|
||||||
|
QSet<FindMatchesJob*> oldSearchJobs;
|
||||||
bool loadAll;
|
bool loadAll;
|
||||||
KConfigGroup config;
|
KConfigGroup config;
|
||||||
};
|
};
|
||||||
|
|
||||||
void FindMatchesJob::setStale()
|
|
||||||
{
|
|
||||||
m_stale = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FindMatchesJob::isStale() const
|
|
||||||
{
|
|
||||||
return m_stale;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
* RunnerManager::Public class
|
* RunnerManager::Public class
|
||||||
*
|
*
|
||||||
@ -274,8 +274,8 @@ void RunnerManager::run(const QueryMatch &match)
|
|||||||
AbstractRunner *runner = match.runner();
|
AbstractRunner *runner = match.runner();
|
||||||
|
|
||||||
foreach (FindMatchesJob *job, d->searchJobs) {
|
foreach (FindMatchesJob *job, d->searchJobs) {
|
||||||
if (job->runner() == runner && !job->isFinished() && !job->isStale()) {
|
if (job->runner() == runner && !job->isFinished()) {
|
||||||
kDebug() << "!!!!!!!!!!!!!!!!!!! uh oh!";
|
kDebug() << "deferred run";
|
||||||
d->deferredRun = match;
|
d->deferredRun = match;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -284,11 +284,8 @@ void RunnerManager::run(const QueryMatch &match)
|
|||||||
if (d->deferredRun.isValid()) {
|
if (d->deferredRun.isValid()) {
|
||||||
d->deferredRun = QueryMatch(0);
|
d->deferredRun = QueryMatch(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
match.run(d->context);
|
match.run(d->context);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QAction*> RunnerManager::actionsForMatch(const QueryMatch &match)
|
QList<QAction*> RunnerManager::actionsForMatch(const QueryMatch &match)
|
||||||
@ -347,7 +344,7 @@ void RunnerManager::launchQuery(const QString &term, const QString &runnerName)
|
|||||||
job->setDelayTimer(&d->delayTimer);
|
job->setDelayTimer(&d->delayTimer);
|
||||||
}
|
}
|
||||||
Weaver::instance()->enqueue(job);
|
Weaver::instance()->enqueue(job);
|
||||||
d->searchJobs.append(job);
|
d->searchJobs.insert(job);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Start timer to unblock slow runners
|
// Start timer to unblock slow runners
|
||||||
@ -390,7 +387,7 @@ bool RunnerManager::execQuery(const QString &term, const QString &runnerName)
|
|||||||
//kDebug() << "ignored!";
|
//kDebug() << "ignored!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->performMatch(d->context);
|
r->performMatch(d->context);
|
||||||
//kDebug() << "succeeded with" << d->context.matches().count() << "results";
|
//kDebug() << "succeeded with" << d->context.matches().count() << "results";
|
||||||
emit matchesChanged(d->context.matches());
|
emit matchesChanged(d->context.matches());
|
||||||
@ -407,16 +404,14 @@ void RunnerManager::reset()
|
|||||||
// If ThreadWeaver is idle, it is safe to clear previous jobs
|
// If ThreadWeaver is idle, it is safe to clear previous jobs
|
||||||
if (Weaver::instance()->isIdle()) {
|
if (Weaver::instance()->isIdle()) {
|
||||||
qDeleteAll(d->searchJobs);
|
qDeleteAll(d->searchJobs);
|
||||||
d->searchJobs.clear();
|
qDeleteAll(d->oldSearchJobs);
|
||||||
} else {
|
} else {
|
||||||
Weaver::instance()->dequeue();
|
Weaver::instance()->dequeue();
|
||||||
// Since we cannot safely delete the jobs, mark them as stale
|
d->oldSearchJobs += d->searchJobs;
|
||||||
// TODO: delete them eventually?
|
|
||||||
foreach (FindMatchesJob *job, d->searchJobs) {
|
|
||||||
job->setStale();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d->searchJobs.clear();
|
||||||
|
|
||||||
if (d->deferredRun.isEnabled()) {
|
if (d->deferredRun.isEnabled()) {
|
||||||
//kDebug() << "job actually done, running now **************";
|
//kDebug() << "job actually done, running now **************";
|
||||||
QueryMatch tmpRun = d->deferredRun;
|
QueryMatch tmpRun = d->deferredRun;
|
||||||
|
Loading…
Reference in New Issue
Block a user