Use QBasicAtomicInt as a static variable
QAtomicInt has a constructor, so QBasicAtomicInt needs to be used instead to allow compile time initialisation. Task-Number: QTBUG-20343 Reviewed-By: Olivier Goffart (cherry picked from commit 29495592d27505feff024d574e1333809794c304) Change-Id: Ia531c74f47daa86ba24a1b01bee36ddb1101af11 Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com>
This commit is contained in:
parent
60b86257b8
commit
25c03a888f
@ -72,10 +72,10 @@ public:
|
||||
|
||||
QMutex mutex;
|
||||
//this is used to avoid (re)constructing factory data from destructors of other global classes
|
||||
static QAtomicInt valid;
|
||||
static QBasicAtomicInt valid;
|
||||
};
|
||||
Q_GLOBAL_STATIC(QNetworkAccessBackendFactoryData, factoryData)
|
||||
QAtomicInt QNetworkAccessBackendFactoryData::valid;
|
||||
QBasicAtomicInt QNetworkAccessBackendFactoryData::valid = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
|
||||
QNetworkAccessBackendFactory::QNetworkAccessBackendFactory()
|
||||
{
|
||||
@ -85,7 +85,7 @@ QNetworkAccessBackendFactory::QNetworkAccessBackendFactory()
|
||||
|
||||
QNetworkAccessBackendFactory::~QNetworkAccessBackendFactory()
|
||||
{
|
||||
if (QNetworkAccessBackendFactoryData::valid) {
|
||||
if (QNetworkAccessBackendFactoryData::valid.load()) {
|
||||
QMutexLocker locker(&factoryData()->mutex);
|
||||
factoryData()->removeAll(this);
|
||||
}
|
||||
@ -94,7 +94,7 @@ QNetworkAccessBackendFactory::~QNetworkAccessBackendFactory()
|
||||
QNetworkAccessBackend *QNetworkAccessManagerPrivate::findBackend(QNetworkAccessManager::Operation op,
|
||||
const QNetworkRequest &request)
|
||||
{
|
||||
if (QNetworkAccessBackendFactoryData::valid) {
|
||||
if (QNetworkAccessBackendFactoryData::valid.load()) {
|
||||
QMutexLocker locker(&factoryData()->mutex);
|
||||
QNetworkAccessBackendFactoryData::ConstIterator it = factoryData()->constBegin(),
|
||||
end = factoryData()->constEnd();
|
||||
|
Loading…
Reference in New Issue
Block a user