diff options
author | Water-Team <water@pad.test.qt.nokia.com> | 2011-10-17 23:00:33 (GMT) |
---|---|---|
committer | Water-Team <water@pad.test.qt.nokia.com> | 2011-10-17 23:00:33 (GMT) |
commit | 923693d4919f22eabd5cec8fb6e855514bb64fb7 (patch) | |
tree | ce5c6ec3f89b9bef3684c748bc4bc39af0d53a9a /src/network | |
parent | ec9a31abf003880a60d1120738a3bee7075b8ca8 (diff) | |
parent | 09e7218a1c30ca33a5d82280f89f07ba54b96555 (diff) | |
download | Qt-923693d4919f22eabd5cec8fb6e855514bb64fb7.zip Qt-923693d4919f22eabd5cec8fb6e855514bb64fb7.tar.gz Qt-923693d4919f22eabd5cec8fb6e855514bb64fb7.tar.bz2 |
Merge branch '4.8-upstream' into master-water
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qnetworkaccessbackend.cpp | 15 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.cpp | 2 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp index 2fae7d6..88c45d1 100644 --- a/src/network/access/qnetworkaccessbackend.cpp +++ b/src/network/access/qnetworkaccessbackend.cpp @@ -57,20 +57,25 @@ QT_BEGIN_NAMESPACE -static bool factoryDataShutdown = false; class QNetworkAccessBackendFactoryData: public QList<QNetworkAccessBackendFactory *> { public: - QNetworkAccessBackendFactoryData() : mutex(QMutex::Recursive) { } + QNetworkAccessBackendFactoryData() : mutex(QMutex::Recursive) + { + valid.ref(); + } ~QNetworkAccessBackendFactoryData() { QMutexLocker locker(&mutex); // why do we need to lock? - factoryDataShutdown = true; + valid.deref(); } QMutex mutex; + //this is used to avoid (re)constructing factory data from destructors of other global classes + static QAtomicInt valid; }; Q_GLOBAL_STATIC(QNetworkAccessBackendFactoryData, factoryData) +QAtomicInt QNetworkAccessBackendFactoryData::valid; QNetworkAccessBackendFactory::QNetworkAccessBackendFactory() { @@ -80,7 +85,7 @@ QNetworkAccessBackendFactory::QNetworkAccessBackendFactory() QNetworkAccessBackendFactory::~QNetworkAccessBackendFactory() { - if (!factoryDataShutdown) { + if (QNetworkAccessBackendFactoryData::valid) { QMutexLocker locker(&factoryData()->mutex); factoryData()->removeAll(this); } @@ -89,7 +94,7 @@ QNetworkAccessBackendFactory::~QNetworkAccessBackendFactory() QNetworkAccessBackend *QNetworkAccessManagerPrivate::findBackend(QNetworkAccessManager::Operation op, const QNetworkRequest &request) { - if (!factoryDataShutdown) { + if (QNetworkAccessBackendFactoryData::valid) { QMutexLocker locker(&factoryData()->mutex); QNetworkAccessBackendFactoryData::ConstIterator it = factoryData()->constBegin(), end = factoryData()->constEnd(); diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 18e29af..96a534d 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -60,7 +60,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, #endif QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() - : QObject(), pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) + : QObject(), pollTimer(0), bearerThread(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) { qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration"); qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer"); |