Fix QNetworkReplyImpl error handling
authorShane Kearns <shane.kearns@accenture.com>
Mon, 18 Apr 2011 14:30:39 +0000 (15:30 +0100)
committerMarkus Goetz <Markus.Goetz@nokia.com>
Mon, 9 May 2011 11:15:23 +0000 (13:15 +0200)
The backend was never started when compiled without bearer management,
now it is.
Now emits the error signal in case of startup errors which would leave
the state machine hanging. Previously it just printed a warning.

Reviewed-by: Peter Hartmann
src/network/access/qnetworkreplyimpl.cpp

index 78e2463..e50f3d6 100644 (file)
@@ -89,10 +89,10 @@ void QNetworkReplyImplPrivate::_q_startOperation()
         return;
     }
 
+    if (!backend->start()) {
 #ifndef QT_NO_BEARERMANAGEMENT
-    if (!backend->start()) { // ### we should call that method even if bearer is not used
         // backend failed to start because the session state is not Connected.
-        // QNetworkAccessManager will call reply->backend->start() again for us when the session
+        // QNetworkAccessManager will call _q_startOperation again for us when the session
         // state changes.
         state = WaitingForSession;
 
@@ -108,11 +108,20 @@ void QNetworkReplyImplPrivate::_q_startOperation()
                 session->open();
         } else {
             qWarning("Backend is waiting for QNetworkSession to connect, but there is none!");
+            state = Working;
+            error(QNetworkReplyImpl::UnknownNetworkError,
+                  QCoreApplication::translate("QNetworkReply", "Network session error."));
+            finished();
         }
-
+#else
+        qWarning("Backend start failed");
+        state = Working;
+        error(QNetworkReplyImpl::UnknownNetworkError,
+              QCoreApplication::translate("QNetworkReply", "backend start error."));
+        finished();
+#endif
         return;
     }
-#endif
 
     if (backend && backend->isSynchronous()) {
         state = Finished;