diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-09-01 05:24:25 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2010-09-02 06:07:40 (GMT) |
commit | 6cd515a866dbf2c80cbaa56a7ed90223ee356cb7 (patch) | |
tree | 645d30c68b8f2058c278dff97567619a931c0d60 | |
parent | 806282f3f9c5d3ed26a0bfae2c512f9346186971 (diff) | |
download | Qt-6cd515a866dbf2c80cbaa56a7ed90223ee356cb7.zip Qt-6cd515a866dbf2c80cbaa56a7ed90223ee356cb7.tar.gz Qt-6cd515a866dbf2c80cbaa56a7ed90223ee356cb7.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
(cherry picked from commit 744ff7738333c35e7d621c61d72422cf3a8e7fe4)
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp index 102b347..fa6af46 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() { |