Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
[libcontacts] Ensure contacts are not in name groups on cache removal
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewvogt committed Oct 11, 2013
1 parent 7f336b3 commit b28d6f3
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/seasidecache.cpp
Expand Up @@ -1383,15 +1383,30 @@ bool SeasideCache::event(QEvent *event)
} else {
m_updatesPending = false;

const QHash<ContactIdType,int> expiredContacts = m_expiredContacts;
QList<quint32> removeIds;

QHash<ContactIdType, int>::const_iterator it = m_expiredContacts.constBegin(), end = m_expiredContacts.constEnd();
for ( ; it != end; ++it) {
if (it.value() < 0) {
quint32 iid = internalId(it.key());
removeIds.append(iid);
}
}
m_expiredContacts.clear();

typedef QHash<ContactIdType,int>::const_iterator iterator;
for (iterator it = expiredContacts.begin(); it != expiredContacts.end(); ++it) {
if (*it >= 0)
continue;
QSet<QString> modifiedGroups;

// Before removal, ensure none of these contacts are in name groups
foreach (quint32 iid, removeIds) {
if (CacheItem *item = existingItem(iid)) {
removeFromContactNameGroup(item->iid, item->nameGroup, &modifiedGroups);
}
}

notifyNameGroupsChanged(modifiedGroups);

quint32 iid = internalId(it.key());
// Remove the contacts from the cache
foreach (quint32 iid, removeIds) {
QHash<quint32, CacheItem>::iterator cacheItem = m_people.find(iid);
if (cacheItem != m_people.end()) {
delete cacheItem->itemData;
Expand Down

0 comments on commit b28d6f3

Please sign in to comment.