required to lower memory consumption for PA4

This commit is contained in:
Aaron Seigo 2012-11-02 13:46:55 +01:00
parent 259c155c9b
commit e30067518f
2 changed files with 45 additions and 2 deletions

View File

@ -483,6 +483,37 @@ bool RunnerContext::removeMatch(const QString matchId)
return true;
}
bool RunnerContext::removeMatches(Plasma::AbstractRunner *runner)
{
if (!isValid()) {
return false;
}
QList<QueryMatch> presentMatchList;
LOCK_FOR_READ(d)
foreach(const QueryMatch &match, d->matches) {
if (match.runner() == runner) {
presentMatchList << match;
}
}
UNLOCK(d)
if (presentMatchList.isEmpty()) {
return false;
}
LOCK_FOR_WRITE(d)
foreach (const QueryMatch &match, presentMatchList) {
d->matchesById.remove(match.id());
d->matches.removeAll(match);
}
UNLOCK(d)
emit d->q->matchesChanged();
return true;
}
QList<QueryMatch> RunnerContext::matches() const
{
LOCK_FOR_READ(d)

View File

@ -179,6 +179,18 @@ class PLASMA_EXPORT RunnerContext : public QObject
*/
bool removeMatches(const QStringList matchIdList);
/**
* Removes lists of matches from a given AbstractRunner
*
* This method is thread safe and causes the matchesChanged() signal to be emitted.
*
* @param runner the AbstractRunner from which to remove matches
*
* @return true if at least one match was removed, false otherwise.
* @since 4.10
*/
bool removeMatches(AbstractRunner *runner);
/**
* Retrieves all available matches for the current search term.
*