summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-03-16 04:00:23 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-03-16 04:00:23 (GMT)
commit6f814d58036867a28333770bd55f5fe49bb9ac82 (patch)
tree5c9b9c3bb1d22b18abe51a71dbd97ef28595b8fa /src
parent077513815c65e70d569b8656935ac7783bf4c974 (diff)
downloadQt-6f814d58036867a28333770bd55f5fe49bb9ac82.zip
Qt-6f814d58036867a28333770bd55f5fe49bb9ac82.tar.gz
Qt-6f814d58036867a28333770bd55f5fe49bb9ac82.tar.bz2
Abort waiting replies on session error.
Abort waiting QNetworkReplys with an error on session errors. Non waiting replies will likely fail by other means (e.g. broken sockets).
Diffstat (limited to 'src')
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp16
-rw-r--r--src/network/access/qnetworkreplyimpl_p.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index b201380..162cff1 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -67,6 +67,8 @@ inline QNetworkReplyImplPrivate::QNetworkReplyImplPrivate()
void QNetworkReplyImplPrivate::_q_startOperation()
{
+ Q_Q(QNetworkReplyImpl);
+
// ensure this function is only being called once
if (state == Working) {
qDebug("QNetworkReplyImpl::_q_startOperation was called more than once");
@@ -93,6 +95,9 @@ void QNetworkReplyImplPrivate::_q_startOperation()
QNetworkSession *session = manager->d_func()->networkSession;
if (session) {
+ QObject::connect(session, SIGNAL(error(QNetworkSession::SessionError)),
+ q, SLOT(_q_networkSessionFailed()));
+
if (!session->isOpen())
session->open();
} else {
@@ -247,6 +252,17 @@ void QNetworkReplyImplPrivate::_q_networkSessionOnline()
}
}
+void QNetworkReplyImplPrivate::_q_networkSessionFailed()
+{
+ // Abort waiting replies.
+ if (state == WaitingForSession) {
+ state = Working;
+ error(QNetworkReplyImpl::UnknownNetworkError,
+ QCoreApplication::translate("QNetworkReply", "Network session error."));
+ finished();
+ }
+}
+
void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const QNetworkRequest &req,
QIODevice *data)
{
diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h
index b4fbd1e..fdcfa33 100644
--- a/src/network/access/qnetworkreplyimpl_p.h
+++ b/src/network/access/qnetworkreplyimpl_p.h
@@ -99,6 +99,7 @@ public:
Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingData())
Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingDataFinished())
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionOnline())
+ Q_PRIVATE_SLOT(d_func(), void _q_networkSessionFailed())
};
class QNetworkReplyImplPrivate: public QNetworkReplyPrivate
@@ -132,6 +133,7 @@ public:
void _q_bufferOutgoingData();
void _q_bufferOutgoingDataFinished();
void _q_networkSessionOnline();
+ void _q_networkSessionFailed();
void setup(QNetworkAccessManager::Operation op, const QNetworkRequest &request,
QIODevice *outgoingData);