"And they lived happily ever after with no more duplicate matches =)"

A local copy of the context is now created in the FindMatchesJob ctor, not anymore in AbstractRunner, this prevents old queries to be run with a valid dptr

svn path=/branches/KDE/4.2/kdelibs/; revision=935345
This commit is contained in:
Jacopo De Simoi 2009-03-04 21:05:24 +00:00
parent a0c4af373d
commit aed33b30e2
2 changed files with 7 additions and 8 deletions

View File

@ -132,14 +132,13 @@ void AbstractRunner::reloadConfiguration()
{
}
void AbstractRunner::performMatch(Plasma::RunnerContext &globalContext)
void AbstractRunner::performMatch(Plasma::RunnerContext &localContext)
{
static const int reasonableRunTime = 1500;
static const int fastEnoughTime = 250;
d->runtime.restart();
//TODO :this is a copy ctor
RunnerContext localContext(globalContext, 0);
match(localContext);
// automatically rate limit runners that become slooow
const int runtime = d->runtime.elapsed();

View File

@ -144,7 +144,7 @@ public:
protected:
void run();
private:
Plasma::RunnerContext *m_context;
Plasma::RunnerContext m_context;
Plasma::AbstractRunner *m_runner;
bool m_stale;
};
@ -152,7 +152,7 @@ private:
FindMatchesJob::FindMatchesJob(Plasma::AbstractRunner *runner,
Plasma::RunnerContext *context, QObject *parent)
: ThreadWeaver::Job(parent),
m_context(context),
m_context(*context, 0),
m_runner(runner),
m_stale(false)
{
@ -165,7 +165,7 @@ void FindMatchesJob::run()
{
// kDebug() << "Running match for " << m_runner->objectName()
// << " in Thread " << thread()->id() << endl;
m_runner->performMatch(*m_context);
m_runner->performMatch(m_context);
}
int FindMatchesJob::priority() const
@ -501,8 +501,8 @@ bool RunnerManager::execQuery(const QString &term, const QString &runnerName)
//kDebug() << "ignored!";
return false;
}
r->performMatch(d->context);
RunnerContext localContext(d->context, 0);
r->performMatch(localContext);
//kDebug() << "succeeded with" << d->context.matches().count() << "results";
emit matchesChanged(d->context.matches());
return true;