diff options
Diffstat (limited to 'src/network/kernel')
-rw-r--r-- | src/network/kernel/qhostinfo.cpp | 29 | ||||
-rw-r--r-- | src/network/kernel/qhostinfo_p.h | 4 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index f287630..28a6c84 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -471,6 +471,18 @@ void QHostInfoRunnable::run() hostInfo.setLookupId(id); resultEmitter.emitResultsReady(hostInfo); + // now also iterate through the postponed ones + QMutableListIterator<QHostInfoRunnable*> iterator(manager->postponedLookups); + while (iterator.hasNext()) { + QHostInfoRunnable* postponed = iterator.next(); + if (toBeLookedUp == postponed->toBeLookedUp) { + // we can now emit + iterator.remove(); + hostInfo.setLookupId(postponed->id); + postponed->resultEmitter.emitResultsReady(hostInfo); + } + } + manager->lookupFinished(this); // thread goes back to QThreadPool @@ -596,6 +608,23 @@ void QHostInfoLookupManager::abortLookup(int id) return; QMutexLocker locker(&this->mutex); + + // is postponed? delete and return + for (int i = 0; i < postponedLookups.length(); i++) { + if (postponedLookups.at(i)->id == id) { + delete postponedLookups.takeAt(i); + return; + } + } + + // is scheduled? delete and return + for (int i = 0; i < scheduledLookups.length(); i++) { + if (scheduledLookups.at(i)->id == id) { + delete scheduledLookups.takeAt(i); + return; + } + } + if (!abortedLookups.contains(id)) abortedLookups.append(id); } diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index e11766b..85d14c2 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -84,7 +84,7 @@ public Q_SLOTS: } Q_SIGNALS: - void resultsReady(const QHostInfo info); + void resultsReady(const QHostInfo &info); }; // needs to be QObject because fromName calls tr() @@ -173,6 +173,8 @@ public: bool wasAborted(int id); QHostInfoCache cache; + + friend class QHostInfoRunnable; protected: QList<QHostInfoRunnable*> currentLookups; // in progress QList<QHostInfoRunnable*> postponedLookups; // postponed because in progress for same host |