From: Ivailo Monev Date: Sat, 23 Nov 2019 15:27:35 +0000 (+0000) Subject: deal with QHostInfo FIXME X-Git-Tag: 4.12.0~5047 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=ee0c09152173daab850be4e7b02f9e6b5b4e65f7;p=kde%2FKatie.git deal with QHostInfo FIXME Signed-off-by: Ivailo Monev --- diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index eb47dc768..bc8bc44da 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -196,12 +196,20 @@ QHostInfo QHostInfo::fromName(const QString &name) qDebug("QHostInfo::fromName(\"%s\")",name.toLatin1().constData()); #endif - QHostInfo hostInfo = QHostInfoAgent::fromName(name); QHostInfoCache* cache = globalHostInfoCache(); if (cache && cache->isEnabled()) { - cache->put(name, hostInfo); + bool valid = false; + QHostInfo info = cache->get(name, &valid); + if (valid) { + return info; + } } - return hostInfo; + + QHostInfo info = QHostInfoAgent::fromName(name); + if (cache && cache->isEnabled()) { + cache->put(name, info); + } + return info; } /*! @@ -427,10 +435,6 @@ QHostInfo QHostInfoCache::get(const QString &name, bool *valid) const return element->info; } - // FIXME idea: - // if too old but not expired, trigger a new lookup - // to freshen our cache - return QHostInfo(); }