Commit 60ad8f72 authored by Lisa's avatar Lisa
Browse files

Group pool used

parent f59ce86b
...@@ -411,21 +411,20 @@ void BackendPrivate::groupQueryFinished() ...@@ -411,21 +411,20 @@ void BackendPrivate::groupQueryFinished()
} }
QFuture< QList< Group* > > const& future = queryGroupFuturePool[uuid]->future(); QFuture< QList< Group* > > const& future = queryGroupFuturePool[uuid]->future();
QList< Group* > result; GroupPool pool;
/* /*
* Since the same groups are repeated across different databases, * Since the same groups are repeated across different databases,
* avoid adding duplicates to the final list. * avoid adding duplicates to the final list.
*/ */
foreach (QList< Group* > res, future.results()) {
foreach (Group* group, res) { foreach (QList< Group* > groupList, future.results()) {
if (!result.contains(group)) { foreach (Group* g, groupList) {
result << group; pool.group( g->name() );
}
} }
} }
emit q->queryGroupsCompleted(uuid, result); emit q->queryGroupsCompleted(uuid, pool.allGroups());
} }
void BackendPrivate::__k__lockGranted(qlonglong pid) void BackendPrivate::__k__lockGranted(qlonglong pid)
...@@ -481,6 +480,12 @@ bool GroupPool::contains(const QString &name) const ...@@ -481,6 +480,12 @@ bool GroupPool::contains(const QString &name) const
return m_pool.contains(name); return m_pool.contains(name);
} }
QList< Group* > GroupPool::allGroups() const
{
QMutexLocker locker(m_mutex);
return m_pool.values();
}
/////////////////////////// ///////////////////////////
class BackendHelper class BackendHelper
......
...@@ -34,6 +34,8 @@ class GroupPool ...@@ -34,6 +34,8 @@ class GroupPool
Group *group(const QString &name); Group *group(const QString &name);
bool contains(const QString &name) const; bool contains(const QString &name) const;
QList< Group* > allGroups() const;
private: private:
GroupPool(); GroupPool();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment