summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Kearns <ext-shane.2.kearns@nokia.com>2012-04-10 17:54:22 +0100
committerQt by Nokia <qt-info@nokia.com>2012-04-11 22:20:10 +0200
commitdc325aab1820029f6f665080fbadfe11a0ff9c7e (patch)
treeb1a91a463c0bc233353b527a546a6e3572db2a97
parent680f35ec1ee7cad8881a5fd9edadc6594cb2fe71 (diff)
Fix error reporting in QNetworkReplyHttpImplPrivate
When errors are detected synchronously in _q_startOperation, they were not reported. This is because unlike the generic QNetworkReplyImpl the function is called directly rather than using a queued connection. In order to report errors, use the _q_error and _q_finished slots so that signals are emitted after returning to the event loop i.e. after the application had a chance to connect the QNetworkReply Change-Id: I8a7bbe79a934f4634fb4e0572ebb5479dfc5f489 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 9aabe4f318..fbddd98998 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -1529,6 +1529,8 @@ bool QNetworkReplyHttpImplPrivate::start()
void QNetworkReplyHttpImplPrivate::_q_startOperation()
{
+ Q_Q(QNetworkReplyHttpImpl);
+
// ensure this function is only being called once
if (state == Working) {
qDebug("QNetworkReplyImpl::_q_startOperation was called more than once");
@@ -1541,9 +1543,10 @@ void QNetworkReplyHttpImplPrivate::_q_startOperation()
QSharedPointer<QNetworkSession> session(manager->d_func()->networkSession);
QVariant isBackground = request.attribute(QNetworkRequest::BackgroundRequestAttribute, QVariant::fromValue(false));
if (isBackground.toBool() && session && session->usagePolicies().testFlag(QNetworkSession::NoBackgroundTrafficPolicy)) {
- error(QNetworkReply::BackgroundRequestNotAllowedError,
- QCoreApplication::translate("QNetworkReply", "Background request not allowed."));
- finished();
+ QMetaObject::invokeMethod(q, "_q_error", synchronous ? Qt::DirectConnection : Qt::QueuedConnection,
+ Q_ARG(QNetworkReply::NetworkError, QNetworkReply::BackgroundRequestNotAllowedError),
+ Q_ARG(QString, QCoreApplication::translate("QNetworkReply", "Background request not allowed.")));
+ QMetaObject::invokeMethod(q, "_q_finished", synchronous ? Qt::DirectConnection : Qt::QueuedConnection);
return;
}
#endif
@@ -1557,8 +1560,6 @@ void QNetworkReplyHttpImplPrivate::_q_startOperation()
QNetworkSession *session = managerPrivate->networkSession.data();
if (session) {
- Q_Q(QNetworkReplyHttpImpl);
-
QObject::connect(session, SIGNAL(error(QNetworkSession::SessionError)),
q, SLOT(_q_networkSessionFailed()));
@@ -1566,9 +1567,20 @@ void QNetworkReplyHttpImplPrivate::_q_startOperation()
session->open();
} else {
qWarning("Backend is waiting for QNetworkSession to connect, but there is none!");
+ QMetaObject::invokeMethod(q, "_q_error", synchronous ? Qt::DirectConnection : Qt::QueuedConnection,
+ Q_ARG(QNetworkReply::NetworkError, QNetworkReply::NetworkSessionFailedError),
+ Q_ARG(QString, QCoreApplication::translate("QNetworkReply", "Network session error.")));
+ QMetaObject::invokeMethod(q, "_q_finished", synchronous ? Qt::DirectConnection : Qt::QueuedConnection);
+ return;
}
-#endif
+#else
+ qWarning("Backend start failed");
+ QMetaObject::invokeMethod(q, "_q_error", synchronous ? Qt::DirectConnection : Qt::QueuedConnection,
+ Q_ARG(QNetworkReply::NetworkError, QNetworkReply::UnknownNetworkError),
+ Q_ARG(QString, QCoreApplication::translate("QNetworkReply", "backend start error.")));
+ QMetaObject::invokeMethod(q, "_q_finished", synchronous ? Qt::DirectConnection : Qt::QueuedConnection);
return;
+#endif
}
if (synchronous) {