diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2010-12-10 03:47:34 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-12-10 03:47:34 (GMT) |
commit | fab1d32dcb32235a34ed735251a27de2a1aaf8ce (patch) | |
tree | 86adb3a94703c6425ad954378fec3fd9b708e510 | |
parent | 32bb6d3ac2c5214a5294123d281cd4d21eaeaf2c (diff) | |
download | Qt-fab1d32dcb32235a34ed735251a27de2a1aaf8ce.zip Qt-fab1d32dcb32235a34ed735251a27de2a1aaf8ce.tar.gz Qt-fab1d32dcb32235a34ed735251a27de2a1aaf8ce.tar.bz2 |
simplify polling code a bit
Merge-request: 899
Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.cpp | 35 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.h | 6 |
2 files changed, 8 insertions, 33 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 022365e..fd1052c 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(), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) { qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration"); qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer"); @@ -442,34 +442,11 @@ void QNetworkConfigurationManagerPrivate::startPolling() { QMutexLocker locker(&mutex); - bool pollingRequired = false; - - if (forcedPolling > 0) { - foreach (QBearerEngine *engine, sessionEngines) { - if (engine->requiresPolling()) { - pollingRequired = true; - break; - } - } - } - - if (!pollingRequired) { - foreach (QBearerEngine *engine, sessionEngines) { - if (engine->configurationsInUse()) { - pollingRequired = true; - break; - } - } - } - - if (pollingRequired) { - if (!pollTimer) { - pollTimer = new QTimer(this); - pollTimer->setInterval(10000); - pollTimer->setSingleShot(true); - connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollEngines())); + foreach (QBearerEngine *engine, sessionEngines) { + if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) { + QTimer::singleShot(10000, this, SLOT(pollEngines())); + break; } - pollTimer->start(); } } @@ -492,7 +469,7 @@ void QNetworkConfigurationManagerPrivate::enablePolling() ++forcedPolling; if (forcedPolling == 1) - QMetaObject::invokeMethod(this, "startPolling"); + startPolling(); } void QNetworkConfigurationManagerPrivate::disablePolling() diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index 9b946d8..16c2c4b 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -64,7 +64,6 @@ QT_BEGIN_NAMESPACE class QBearerEngine; -class QTimer; class Q_NETWORK_EXPORT QNetworkConfigurationManagerPrivate : public QObject { @@ -86,8 +85,6 @@ public: QList<QBearerEngine *> engines() const; - Q_INVOKABLE void startPolling(); - void enablePolling(); void disablePolling(); @@ -109,8 +106,9 @@ private Q_SLOTS: void pollEngines(); private: - QTimer *pollTimer; + void startPolling(); +private: mutable QMutex mutex; QList<QBearerEngine *> sessionEngines; |