summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorShane Kearns <ext-shane.2.kearns@nokia.com>2012-05-30 16:08:16 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-06-06 13:31:21 (GMT)
commitbd501eeebfad5ed8fe6d29a9c2c0a26f844bef58 (patch)
tree59a1ee065e5a527c2bc8d833092237f35015d0a4 /src/network
parent7cbfa66a3e0e03ec559c3b029c817c946bd5c165 (diff)
downloadQt-bd501eeebfad5ed8fe6d29a9c2c0a26f844bef58.zip
Qt-bd501eeebfad5ed8fe6d29a9c2c0a26f844bef58.tar.gz
Qt-bd501eeebfad5ed8fe6d29a9c2c0a26f844bef58.tar.bz2
Track active network replies without qFindChildren
For bearer management to work correctly, we need to know when there are no network replies active. Previously this was implemented using qFindChildren, but that doesn't work when the user reparents QNetworkReply. QtWebkit does this (actually sets parent to 0). Also the qFindChildren implementation was racy if multiple requests were finished in parallel. Again, likely to be triggered by webkit loading page elements. Task-number: QTBUG-15812 Change-Id: I181a9ba6611c7c4b6fffa2d84fe4029d89e8f596 Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com> (cherry picked from commit 3580168c3e357c2289acddc5f2515a3ad306ef2b)
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp6
-rw-r--r--src/network/access/qnetworkaccessmanager_p.h2
2 files changed, 7 insertions, 1 deletions
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 9204a89..768c135 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -1014,7 +1014,8 @@ void QNetworkAccessManagerPrivate::_q_replyFinished()
// If there are no active requests, release our reference to the network session.
// It will not be destroyed immediately, but rather when the connection cache is flushed
// after 2 minutes.
- if (networkSession && q->findChildren<QNetworkReply *>().count() == 1)
+ activeReplyCount--;
+ if (networkSession && activeReplyCount == 0)
networkSession.clear();
#endif
}
@@ -1041,6 +1042,9 @@ QNetworkReply *QNetworkAccessManagerPrivate::postProcess(QNetworkReply *reply)
* avoid getting a connection error. */
q->connect(reply, SIGNAL(sslErrors(QList<QSslError>)), SLOT(_q_replySslErrors(QList<QSslError>)));
#endif
+#ifndef QT_NO_BEARERMANAGEMENT
+ activeReplyCount++;
+#endif
return reply;
}
diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h
index 2f884f4..ddacf68 100644
--- a/src/network/access/qnetworkaccessmanager_p.h
+++ b/src/network/access/qnetworkaccessmanager_p.h
@@ -81,6 +81,7 @@ public:
networkSession(0),
lastSessionState(QNetworkSession::Invalid),
networkAccessible(QNetworkAccessManager::Accessible),
+ activeReplyCount(0),
online(false),
initializeSession(true),
#endif
@@ -140,6 +141,7 @@ public:
QNetworkSession::State lastSessionState;
QString networkConfiguration;
QNetworkAccessManager::NetworkAccessibility networkAccessible;
+ int activeReplyCount;
bool online;
bool initializeSession;
#endif