summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2010-03-22 12:06:29 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2010-03-22 12:29:30 (GMT)
commit22993cbada46fb9e170d4ac7a08413c968fce2a2 (patch)
tree50513b3bd4ad22c55989fd312f8a1ed64fb9486d
parent28d469475ccb708ab3f141d9e3c48a24dff4b5e1 (diff)
downloadQt-22993cbada46fb9e170d4ac7a08413c968fce2a2.zip
Qt-22993cbada46fb9e170d4ac7a08413c968fce2a2.tar.gz
Qt-22993cbada46fb9e170d4ac7a08413c968fce2a2.tar.bz2
Stop QHostInfo thread pool when application is about to exit
Ensure that the threadpool QHostInfo uses internally has cleanup its threads when the application exits. This avoids the warning from QWaitCondition on Windows (which happens due to thread termination at application exit). Task-number: QTBUG-7691 Reviewed-by: mgoetz
-rw-r--r--src/network/kernel/qhostinfo.cpp1
-rw-r--r--src/network/kernel/qhostinfo_p.h3
2 files changed, 4 insertions, 0 deletions
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp
index 7150fb7..6894978 100644
--- a/src/network/kernel/qhostinfo.cpp
+++ b/src/network/kernel/qhostinfo.cpp
@@ -479,6 +479,7 @@ void QHostInfoRunnable::run()
QHostInfoLookupManager::QHostInfoLookupManager() : mutex(QMutex::Recursive), wasDeleted(false)
{
moveToThread(QCoreApplicationPrivate::mainThread());
+ connect(QCoreApplication::instance(), SIGNAL(destroyed()), SLOT(waitForThreadPoolDone()), Qt::DirectConnection);
threadPool.setMaxThreadCount(5); // do 5 DNS lookups in parallel
}
diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h
index 2b26b07..4fc74e9 100644
--- a/src/network/kernel/qhostinfo_p.h
+++ b/src/network/kernel/qhostinfo_p.h
@@ -184,6 +184,9 @@ protected:
QMutex mutex;
bool wasDeleted;
+
+private slots:
+ void waitForThreadPoolDone() { threadPool.waitForDone(); }
};
#endif