summaryrefslogtreecommitdiffstats
path: root/src/network/bearer
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@nokia.com>2011-06-24 09:52:41 (GMT)
committerLiang Qi <liang.qi@nokia.com>2011-06-24 09:52:41 (GMT)
commitcf2f72f4f61f3a9e0e7573379c33bb341eeba7be (patch)
tree06fbd459f62f87344e7db973a0a9f3050cece825 /src/network/bearer
parent164728f711136356a6c3482f762321b01c9d82dd (diff)
parent705b0f958a6071341b10cbd51917e1378356491b (diff)
downloadQt-cf2f72f4f61f3a9e0e7573379c33bb341eeba7be.zip
Qt-cf2f72f4f61f3a9e0e7573379c33bb341eeba7be.tar.gz
Qt-cf2f72f4f61f3a9e0e7573379c33bb341eeba7be.tar.bz2
Merge remote-tracking branch 'origin/4.7' into qt-4.8-from-4.7
Conflicts: src/gui/image/qpixmap_raster_symbian.cpp src/gui/image/qpixmapdatafactory.cpp src/gui/painting/qgraphicssystem.cpp src/gui/styles/qs60style.cpp src/network/bearer/qnetworkconfigmanager_p.h src/s60installs/bwins/QtGuiu.def src/s60installs/bwins/QtOpenGLu.def src/s60installs/bwins/QtOpenVGu.def src/s60installs/eabi/QtGuiu.def src/s60installs/eabi/QtOpenVGu.def tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
Diffstat (limited to 'src/network/bearer')
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp4
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.cpp39
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.h3
3 files changed, 33 insertions, 13 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index 666aba7..fdb36e8 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
= { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
static void NAME##_cleanup() \
{ \
- delete this_##NAME.pointer; \
+ this_##NAME.pointer->cleanup(); \
this_##NAME.pointer = 0; \
} \
static TYPE *NAME() \
@@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE
delete x; \
else { \
qAddPostRoutine(NAME##_cleanup); \
- this_##NAME.pointer->updateConfigurations(); \
+ this_##NAME.pointer->initialize(); \
} \
} \
return this_##NAME.pointer; \
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp
index d468bc4..18e29af 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.cpp
+++ b/src/network/bearer/qnetworkconfigmanager_p.cpp
@@ -66,11 +66,31 @@ QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate()
qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer");
}
+void QNetworkConfigurationManagerPrivate::initialize()
+{
+ //Two stage construction, because we only want to do this heavyweight work for the winner of the Q_GLOBAL_STATIC race.
+ bearerThread = new QThread();
+ bearerThread->moveToThread(QCoreApplicationPrivate::mainThread()); // because cleanup() is called in main thread context.
+ moveToThread(bearerThread);
+ bearerThread->start();
+ updateConfigurations();
+}
+
QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate()
{
QMutexLocker locker(&mutex);
qDeleteAll(sessionEngines);
+ if (bearerThread)
+ bearerThread->quit();
+}
+
+void QNetworkConfigurationManagerPrivate::cleanup()
+{
+ QThread* thread = bearerThread;
+ deleteLater();
+ if(thread->wait(5000))
+ delete thread;
}
QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration() const
@@ -350,13 +370,6 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
if (qobject_cast<QBearerEngine *>(sender()))
return;
- if (thread() != QCoreApplicationPrivate::mainThread()) {
- if (thread() != QThread::currentThread())
- return;
-
- moveToThread(QCoreApplicationPrivate::mainThread());
- }
-
updating = false;
#ifndef QT_NO_LIBRARY
@@ -375,7 +388,7 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
else
sessionEngines.append(engine);
- engine->moveToThread(QCoreApplicationPrivate::mainThread());
+ engine->moveToThread(bearerThread);
connect(engine, SIGNAL(updateCompleted()),
this, SLOT(updateConfigurations()));
@@ -385,8 +398,6 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer)));
connect(engine, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)));
-
- QMetaObject::invokeMethod(engine, "initialize");
}
}
@@ -410,8 +421,14 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
startPolling();
}
- if (firstUpdate)
+ if (firstUpdate) {
firstUpdate = false;
+ QList<QBearerEngine*> enginesToInitialize = sessionEngines; //shallow copy the list in case it is modified when we unlock mutex
+ locker.unlock();
+ foreach (QBearerEngine* engine, enginesToInitialize) {
+ QMetaObject::invokeMethod(engine, "initialize", Qt::BlockingQueuedConnection);
+ }
+ }
}
void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate()
diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h
index 04cce20..56f66b4 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.h
+++ b/src/network/bearer/qnetworkconfigmanager_p.h
@@ -89,6 +89,8 @@ public:
void enablePolling();
void disablePolling();
+ void initialize();
+ void cleanup();
public Q_SLOTS:
void updateConfigurations();
@@ -109,6 +111,7 @@ private Q_SLOTS:
private:
Q_INVOKABLE void startPolling();
QTimer *pollTimer;
+ QThread *bearerThread;
private:
mutable QMutex mutex;