zeroconf: fix triggerRefresh (but at cost of polling every 5 sec)

Change-Id: Ifc08553f7469947f657d938dbaae3f0011c51482
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@nokia.com>
This commit is contained in:
Fawzi Mohamed
2012-02-22 20:27:35 +01:00
parent 2f86d5c336
commit f175437493

View File

@@ -1240,7 +1240,7 @@ void ServiceBrowserPrivate::maybeUpdateLists()
QMap<QString, ServiceGatherer::Ptr>::iterator j = gatherers.begin(); QMap<QString, ServiceGatherer::Ptr>::iterator j = gatherers.begin();
while (i != endi && j != gatherers.end()) { while (i != endi && j != gatherers.end()) {
const QString vi = *i; const QString vi = *i;
QString vj = (*j)->fullName(); QString vj = j.value()->fullName();
if (vi == vj){ if (vi == vj){
++i; ++i;
++j; ++j;
@@ -1364,13 +1364,15 @@ bool ServiceBrowserPrivate::internalStartBrowsing()
void ServiceBrowserPrivate::triggerRefresh() void ServiceBrowserPrivate::triggerRefresh()
{ {
QMutexLocker l(mainConnection->lock()); QMutexLocker l(mainConnection->lock());
const qint64 msecDelay = 5100;
delayDeletesUntil = QDateTime::currentMSecsSinceEpoch() + msecDelay;
stopBrowsing(); stopBrowsing();
shouldRefresh = true; shouldRefresh = true;
} }
void ServiceBrowserPrivate::refresh() void ServiceBrowserPrivate::refresh()
{ {
const qint64 msecDelay = 100; const qint64 msecDelay = 500;
delayDeletesUntil = QDateTime::currentMSecsSinceEpoch() + msecDelay; delayDeletesUntil = QDateTime::currentMSecsSinceEpoch() + msecDelay;
shouldRefresh = false; shouldRefresh = false;
internalStartBrowsing(); internalStartBrowsing();
@@ -1386,6 +1388,8 @@ void ServiceBrowserPrivate::stopBrowsing()
updateFlowStatusForCancel(); updateFlowStatusForCancel();
serviceConnection = 0; serviceConnection = 0;
} }
knownServices.clear();
browsing = false;
} }
} }
@@ -1667,9 +1671,10 @@ ZConfLib::RunLoopStatus MainConnection::handleEvent()
nextEvent = bAtt->delayDeletesUntil; nextEvent = bAtt->delayDeletesUntil;
} }
if (nextEvent <= now) if (nextEvent <= now)
nextEvent = -1; nextEvent = 5000;
else else
nextEvent -= now; nextEvent -= now;
maybeUpdateLists();
ZConfLib::RunLoopStatus err = lib->processOneEvent(m_mainRef, nextEvent); ZConfLib::RunLoopStatus err = lib->processOneEvent(m_mainRef, nextEvent);
if (err != ZConfLib::ProcessedOk && err != ZConfLib::ProcessedIdle) { if (err != ZConfLib::ProcessedOk && err != ZConfLib::ProcessedIdle) {
qDebug() << "processOneEvent returned " << err; qDebug() << "processOneEvent returned " << err;