summaryrefslogtreecommitdiffstats
path: root/src/network/bearer/qnetworkconfigmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/bearer/qnetworkconfigmanager.cpp')
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index 855ab4e485..db1325d85b 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -57,6 +57,13 @@ QT_BEGIN_NAMESPACE
static QBasicAtomicPointer<QNetworkConfigurationManagerPrivate> connManager_ptr;
static QBasicAtomicInt appShutdown;
+static void connManager_prepare()
+{
+ int shutdown = appShutdown.fetchAndStoreAcquire(0);
+ Q_ASSERT(shutdown == 0 || shutdown == 1);
+ Q_UNUSED(shutdown);
+}
+
static void connManager_cleanup()
{
// this is not atomic or thread-safe!
@@ -68,8 +75,9 @@ static void connManager_cleanup()
cmp->cleanup();
}
-void QNetworkConfigurationManagerPrivate::addPostRoutine()
+void QNetworkConfigurationManagerPrivate::addPreAndPostRoutine()
{
+ qAddPreRoutine(connManager_prepare);
qAddPostRoutine(connManager_cleanup);
}
@@ -85,12 +93,12 @@ QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
if (QCoreApplicationPrivate::mainThread() == QThread::currentThread()) {
// right thread or no main thread yet
- ptr->addPostRoutine();
+ ptr->addPreAndPostRoutine();
ptr->initialize();
} else {
// wrong thread, we need to make the main thread do this
QObject *obj = new QObject;
- QObject::connect(obj, SIGNAL(destroyed()), ptr, SLOT(addPostRoutine()), Qt::DirectConnection);
+ QObject::connect(obj, SIGNAL(destroyed()), ptr, SLOT(addPreAndPostRoutine()), Qt::DirectConnection);
ptr->initialize(); // this moves us to the right thread
obj->moveToThread(QCoreApplicationPrivate::mainThread());
obj->deleteLater();