src/network/access/qhttpnetworkconnection.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 22 79de32ba3296
--- a/src/network/access/qhttpnetworkconnection.cpp	Fri Apr 16 15:50:13 2010 +0300
+++ b/src/network/access/qhttpnetworkconnection.cpp	Mon May 03 13:17:34 2010 +0300
@@ -416,13 +416,25 @@
         lowPriorityQueue.prepend(pair);
         break;
     }
+
     // this used to be called via invokeMethod and a QueuedConnection
+    // It is the only place _q_startNextRequest is called directly without going
+    // through the event loop using a QueuedConnection.
+    // This is dangerous because of recursion that might occur when emitting
+    // signals as DirectConnection from this code path. Therefore all signal
+    // emissions that can come out from this code path need to
+    // be QueuedConnection.
+    // We are currently trying to fine-tune this.
     _q_startNextRequest();
+
+
     return reply;
 }
 
 void QHttpNetworkConnectionPrivate::requeueRequest(const HttpMessagePair &pair)
 {
+    Q_Q(QHttpNetworkConnection);
+
     QHttpNetworkRequest request = pair.first;
     switch (request.priority()) {
     case QHttpNetworkRequest::HighPriority:
@@ -433,8 +445,8 @@
         lowPriorityQueue.prepend(pair);
         break;
     }
-    // this used to be called via invokeMethod and a QueuedConnection
-    _q_startNextRequest();
+
+    QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
 }
 
 void QHttpNetworkConnectionPrivate::dequeueAndSendRequest(QAbstractSocket *socket)
@@ -682,6 +694,8 @@
 
 
 
+// This function must be called from the event loop. The only
+// exception is documented in QHttpNetworkConnectionPrivate::queueRequest
 void QHttpNetworkConnectionPrivate::_q_startNextRequest()
 {
     //resend the necessary ones.