summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-09-01 05:24:25 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-09-01 06:49:28 (GMT)
commit744ff7738333c35e7d621c61d72422cf3a8e7fe4 (patch)
tree7d5684c8755ccb4f2c5d624033e1dd32a40c760f /src/network
parent1d77ce9a00b959befd56428152a52db16743db42 (diff)
downloadQt-744ff7738333c35e7d621c61d72422cf3a8e7fe4.zip
Qt-744ff7738333c35e7d621c61d72422cf3a8e7fe4.tar.gz
Qt-744ff7738333c35e7d621c61d72422cf3a8e7fe4.tar.bz2
Destroy QNetworkConfigurationManager global static from qApp dtor.
The order of global static destruction is not well defined. Ensure that the QNetworkConfigurationManager global static is destroyed from the QCoreApplication destructor before its dependencies are destroyed with the rest of the global statics. Task-number: QTBUG-13304
Diffstat (limited to 'src/network')
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index 65014a6..23d7800 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -45,12 +45,33 @@
#include "qbearerengine_p.h"
#include <QtCore/qstringlist.h>
+#include <QtCore/qcoreapplication.h>
#ifndef QT_NO_BEARERMANAGEMENT
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC(QNetworkConfigurationManagerPrivate, connManager);
+#define Q_GLOBAL_STATIC_QAPP_DESTRUCTION(TYPE, NAME) \
+ Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
+ static void NAME##_cleanup() \
+ { \
+ delete this_##NAME.pointer; \
+ this_##NAME.pointer = 0; \
+ this_##NAME.destroyed = true; \
+ } \
+ static TYPE *NAME() \
+ { \
+ if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
+ TYPE *x = new TYPE; \
+ if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \
+ delete x; \
+ else \
+ qAddPostRoutine(NAME##_cleanup); \
+ } \
+ return this_##NAME.pointer; \
+ }
+
+Q_GLOBAL_STATIC_QAPP_DESTRUCTION(QNetworkConfigurationManagerPrivate, connManager);
QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
{