[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/4.2/kdelibs/plasma
From: Jacopo De Simoi <wilderkde () gmail ! com>
Date: 2009-03-03 7:52:25
Message-ID: 1236066745.860401.22335.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 934465 by jacopods:
Added a way to flag old searchJobs as stale, make sure that obsoleted matches do not \
interfere with new ones, corrected a misplaced brace in the previous commit
M +17 -4 runnercontext.cpp
M +25 -5 runnermanager.cpp
--- branches/KDE/4.2/kdelibs/plasma/runnercontext.cpp #934464:934465
@@ -142,8 +142,15 @@
{
// We will detach if we are a copy of someone. But we will reset
// if we are the 'main' context others copied from. Resetting
- // one RunnerContext makes all the copies oneobsolete.
+ // one RunnerContext makes all the copies obsolete.
+
+ d->q = 0; //we need to mark the q pointer of the detached RunnerContextPrivate
+ //as dirty on detach to avoid receiving results for old queries
+
d.detach();
+
+ d->q = this; //now that we detached the d pointer we need to mark its q pointer \
as + //this to receive the signals
// we still have to remove all the matches, since if the
// ref count was 1 (e.g. only the RunnerContext is using
@@ -151,7 +158,7 @@
if (!d->matches.isEmpty()) {
d->matchesById.clear();
d->matches.clear();
- emit d->q->matchesChanged();
+ emit matchesChanged();
}
d->term.clear();
@@ -194,7 +201,7 @@
{
Q_UNUSED(term)
- if (matches.isEmpty()) {
+ if (matches.isEmpty() || (!d->q)) { //Bail out if the query is empty or the qptr \
is dirty return false;
}
@@ -214,6 +221,7 @@
// we always want to sent the signal of the object that created
// the d pointer
emit d->q->matchesChanged();
+
return true;
}
@@ -221,12 +229,17 @@
{
Q_UNUSED(term)
+ if (!d->q) { // Bail out if the qptr is dirty
+ return false;
+ }
+
LOCK_FOR_WRITE(this)
d->matches.append(match);
d->matchesById.insert(match.id(), &d->matches.at(d->matches.size() - 1));
UNLOCK(this);
//kDebug()<< "added match" << match->text();
- emit d->q->matchesChanged();
+ emit d->q->matchesChanged();
+
return true;
}
--- branches/KDE/4.2/kdelibs/plasma/runnermanager.cpp #934464:934465
@@ -138,19 +138,23 @@
int priority() const;
Plasma::AbstractRunner *runner() const;
+ void setStale();
+ bool isStale() const;
protected:
void run();
private:
Plasma::RunnerContext *m_context;
Plasma::AbstractRunner *m_runner;
+ bool m_stale;
};
FindMatchesJob::FindMatchesJob(Plasma::AbstractRunner *runner,
Plasma::RunnerContext *context, QObject *parent)
: ThreadWeaver::Job(parent),
m_context(context),
- m_runner(runner)
+ m_runner(runner),
+ m_stale(false)
{
if (runner->speed() == Plasma::AbstractRunner::SlowSpeed) {
assignQueuePolicy(&RunnerRestrictionPolicy::instance());
@@ -174,6 +178,16 @@
return m_runner;
}
+void FindMatchesJob::setStale()
+{
+ m_stale = true;
+}
+
+bool FindMatchesJob::isStale() const
+{
+ return m_stale;
+}
+
/*****************************************************
* RunnerManager::Private class
*
@@ -376,8 +390,8 @@
AbstractRunner *runner = match.runner();
foreach (FindMatchesJob *job, d->searchJobs) {
- if (job->runner() == runner && !job->isFinished()) {
- //kDebug() << "!!!!!!!!!!!!!!!!!!! uh oh!";
+ if (job->runner() == runner && !job->isFinished() && !job->isStale()) {
+ kDebug() << "!!!!!!!!!!!!!!!!!!! uh oh!";
d->deferredRun = match;
return;
}
@@ -385,11 +399,12 @@
if (d->deferredRun.isValid()) {
d->deferredRun = QueryMatch(0);
-
+ }
+
match.run(d->context);
- }
+
}
QList<QAction*> RunnerManager::actionsForMatch(const QueryMatch &match)
@@ -506,6 +521,11 @@
d->searchJobs.clear();
} 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();
+ }
}
if (d->deferredRun.isEnabled()) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic