--- a/src/network/bearer/qnetworkconfigmanager_p.cpp Fri Sep 17 08:34:18 2010 +0300
+++ b/src/network/bearer/qnetworkconfigmanager_p.cpp Mon Oct 04 01:19:32 2010 +0300
@@ -63,9 +63,7 @@
: pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true)
{
qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration");
-
- moveToThread(QCoreApplicationPrivate::mainThread());
- updateConfigurations();
+ qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer");
}
QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate()
@@ -150,25 +148,29 @@
end = engine->accessPointConfigurations.end(); it != end; ++it) {
QNetworkConfigurationPrivatePointer ptr = it.value();
- const QString bearerName = ptr->bearerName();
QMutexLocker configLocker(&ptr->mutex);
+ QNetworkConfiguration::BearerType bearerType = ptr->bearerType;
if ((ptr->state & QNetworkConfiguration::Discovered) ==
QNetworkConfiguration::Discovered) {
if (!defaultConfiguration) {
defaultConfiguration = ptr;
} else {
+ QMutexLocker defaultConfigLocker(&defaultConfiguration->mutex);
+
if (defaultConfiguration->state == ptr->state) {
- if (defaultConfiguration->bearerName() == QLatin1String("Ethernet")) {
+ switch (defaultConfiguration->bearerType) {
+ case QNetworkConfiguration::BearerEthernet:
// do nothing
- } else if (defaultConfiguration->bearerName() == QLatin1String("WLAN")) {
- // ethernet beats wlan
- if (bearerName == QLatin1String("Ethernet"))
- defaultConfiguration = ptr;
- } else {
- // ethernet and wlan beats other
- if (bearerName == QLatin1String("Ethernet") ||
- bearerName == QLatin1String("WLAN")) {
+ break;
+ case QNetworkConfiguration::BearerWLAN:
+ // Ethernet beats WLAN
+ defaultConfiguration = ptr;
+ break;
+ default:
+ // Ethernet and WLAN beats other
+ if (bearerType == QNetworkConfiguration::BearerEthernet ||
+ bearerType == QNetworkConfiguration::BearerWLAN) {
defaultConfiguration = ptr;
}
}
@@ -354,6 +356,13 @@
if (sender())
return;
+ if (thread() != QCoreApplicationPrivate::mainThread()) {
+ if (thread() != QThread::currentThread())
+ return;
+
+ moveToThread(QCoreApplicationPrivate::mainThread());
+ }
+
updating = false;
#ifndef QT_NO_LIBRARY