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

Commit

Permalink
Browse files Browse the repository at this point in the history
[libcontacts] make sure UpdateRequest processing continues
The logic for scheduling UpdateRequest events broke down when
m_contactsToAppend went empty during a fetch request; even though
more contacts were coming in through contactsAvailable, no more
UpdateRequest events would be scheduled until the whole request
was complete.

Fixed by making m_updatesPending the definitive flag for whether
there is an UpdateRequest event on the queue, rather than leaving
it on during the whole fetch request.

This change is safe because the flag was only inspected by the
requestUpdate() helper and had no side meanings. Now all
UpdateRequest event scheduling goes through requestUpdate().
  • Loading branch information
amtep committed Sep 12, 2014
1 parent 1707297 commit ff84e74
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/seasidecache.cpp
Expand Up @@ -1751,6 +1751,7 @@ bool SeasideCache::event(QEvent *event)
if (event->type() != QEvent::UpdateRequest)
return QObject::event(event);

m_updatesPending = false;
bool idleProcessing = false;
startRequest(&idleProcessing);

Expand All @@ -1766,14 +1767,11 @@ bool SeasideCache::event(QEvent *event)
applyPendingContactUpdates();

// Send another event to trigger further processing
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
requestUpdate();
return true;
}

if (idleProcessing) {
// We have nothing pending to do
m_updatesPending = false;

// Remove expired contacts when all other activity has been processed
if (!m_expiredContacts.isEmpty()) {
QList<quint32> removeIds;
Expand Down Expand Up @@ -2217,6 +2215,7 @@ void SeasideCache::contactsAvailable()
} else {
m_contactsToAppend.insert(type, qMakePair(queryDetailTypes, contacts));
}
requestUpdate();
} else {
if (m_activeResolve || (request == &m_fetchByIdRequest)) {
// Process these results immediately
Expand Down Expand Up @@ -2704,7 +2703,7 @@ void SeasideCache::requestStateChanged(QContactAbstractRequest::State state)
}

// See if there are any more requests to dispatch
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
requestUpdate();
}

void SeasideCache::makePopulated(FilterType filter)
Expand Down

0 comments on commit ff84e74

Please sign in to comment.