summaryrefslogtreecommitdiffstats
path: root/src/network/bearer/qnetworkconfigmanager_p.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/bearer/qnetworkconfigmanager_p.cpp')
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp
index 2391a34..17e47bd 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.cpp
+++ b/src/network/bearer/qnetworkconfigmanager_p.cpp
@@ -66,11 +66,31 @@ QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate()
qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer");
}
+void QNetworkConfigurationManagerPrivate::initialize()
+{
+ //Two stage construction, because we only want to do this heavyweight work for the winner of the Q_GLOBAL_STATIC race.
+ bearerThread = new QThread();
+ bearerThread->moveToThread(QCoreApplicationPrivate::mainThread()); // because cleanup() is called in main thread context.
+ moveToThread(bearerThread);
+ bearerThread->start();
+ updateConfigurations();
+}
+
QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate()
{
QMutexLocker locker(&mutex);
qDeleteAll(sessionEngines);
+ if (bearerThread)
+ bearerThread->quit();
+}
+
+void QNetworkConfigurationManagerPrivate::cleanup()
+{
+ QThread* thread = bearerThread;
+ deleteLater();
+ if(thread->wait(5000))
+ delete thread;
}
QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration()
@@ -356,13 +376,6 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
if (sender())
return;
- if (thread() != QCoreApplicationPrivate::mainThread()) {
- if (thread() != QThread::currentThread())
- return;
-
- moveToThread(QCoreApplicationPrivate::mainThread());
- }
-
updating = false;
#ifndef QT_NO_LIBRARY
@@ -382,7 +395,7 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
else
sessionEngines.append(engine);
- engine->moveToThread(QCoreApplicationPrivate::mainThread());
+ engine->moveToThread(bearerThread);
connect(engine, SIGNAL(updateCompleted()),
this, SLOT(updateConfigurations()));
@@ -424,14 +437,9 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
if (firstUpdate) {
firstUpdate = false;
QList<QBearerEngine*> enginesToInitialize = sessionEngines; //shallow copy the list in case it is modified when we unlock mutex
- Qt::ConnectionType connectionType;
- if (QCoreApplicationPrivate::mainThread() == QThread::currentThread())
- connectionType = Qt::DirectConnection;
- else
- connectionType = Qt::BlockingQueuedConnection;
locker.unlock();
foreach (QBearerEngine* engine, enginesToInitialize) {
- QMetaObject::invokeMethod(engine, "initialize", connectionType);
+ QMetaObject::invokeMethod(engine, "initialize", Qt::BlockingQueuedConnection);
}
}
}