summaryrefslogtreecommitdiffstats
path: root/src/plugins/bearer/generic/qgenericengine.cpp
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-03-08 03:04:13 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-03-11 22:27:21 (GMT)
commitcf69144f2b5511c6e4e81bd9da8ee6acd2340e5c (patch)
tree5df42e812b7c824486cc8ae7f333e99e5b5bd176 /src/plugins/bearer/generic/qgenericengine.cpp
parent0b2190dad38cbe4c8245d500a0fc7cf6f69cc0da (diff)
downloadQt-cf69144f2b5511c6e4e81bd9da8ee6acd2340e5c.zip
Qt-cf69144f2b5511c6e4e81bd9da8ee6acd2340e5c.tar.gz
Qt-cf69144f2b5511c6e4e81bd9da8ee6acd2340e5c.tar.bz2
Make QNetworkConfigurationManager and QNetworkConfiguration threadsafe.
Diffstat (limited to 'src/plugins/bearer/generic/qgenericengine.cpp')
-rw-r--r--src/plugins/bearer/generic/qgenericengine.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp
index a9e78b2..dfc74f2 100644
--- a/src/plugins/bearer/generic/qgenericengine.cpp
+++ b/src/plugins/bearer/generic/qgenericengine.cpp
@@ -50,6 +50,7 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qdebug.h>
+#include <QtCore/private/qcoreapplication_p.h>
#ifdef Q_OS_WIN
#include "../platformdefs_win.h"
@@ -174,8 +175,6 @@ void QGenericEngine::disconnectFromId(const QString &id)
void QGenericEngine::requestUpdate()
{
- QMutexLocker locker(&mutex);
-
doRequestUpdate();
}
@@ -231,6 +230,8 @@ void QGenericEngine::doRequestUpdate()
bool changed = false;
+ ptr->mutex.lock();
+
if (!ptr->isValid) {
ptr->isValid = true;
changed = true;
@@ -251,8 +252,13 @@ void QGenericEngine::doRequestUpdate()
changed = true;
}
- if (changed)
+ ptr->mutex.unlock();
+
+ if (changed) {
+ locker.unlock();
emit configurationChanged(ptr);
+ locker.relock();
+ }
} else {
QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate);
@@ -266,7 +272,9 @@ void QGenericEngine::doRequestUpdate()
accessPointConfigurations.insert(id, ptr);
configurationInterface.insert(id, interface.name());
+ locker.unlock();
emit configurationAdded(ptr);
+ locker.relock();
}
}
@@ -275,9 +283,13 @@ void QGenericEngine::doRequestUpdate()
accessPointConfigurations.take(previous.takeFirst());
configurationInterface.remove(ptr->id);
+
+ locker.unlock();
emit configurationRemoved(ptr);
+ locker.relock();
}
+ locker.unlock();
emit updateCompleted();
}
@@ -290,6 +302,8 @@ QNetworkSession::State QGenericEngine::sessionStateForId(const QString &id)
if (!ptr)
return QNetworkSession::Invalid;
+ QMutexLocker configLocker(&ptr->mutex);
+
if (!ptr->isValid) {
return QNetworkSession::Invalid;
} else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {