diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2018-07-30 17:16:01 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2018-07-31 14:57:02 +0000 |
commit | 2dfa41e0eac65f5772ec61364f9afd0ce49fecc7 (patch) | |
tree | 958ff5a71a2a9341d7d70a92a1c19a118c5ef9e4 /src/network/access/qhttpnetworkconnectionchannel.cpp | |
parent | f43e947dc405b6a2324656f631c804db8e8dec3d (diff) |
Return to eventloop after emitting encrypted
When the connection has been encrypted we will,
in QHttpNetworkConnectionChannel::_q_encrypted, emit 'reply->encrypted'
in which user slots can be called.
In the event that the user calls abort it will, however, not abort until
the next time it goes back to the event loop (which might not happen
until after the request has already been sent).
Task-number: QTBUG-65960
Change-Id: I96865f83c47f89deb9f644c86a71948dbb0ec0d0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network/access/qhttpnetworkconnectionchannel.cpp')
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 0ac14c78f6..5726925cb0 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -251,6 +251,20 @@ bool QHttpNetworkConnectionChannel::sendRequest() return protocolHandler->sendRequest(); } +/* + * Invoke "protocolHandler->sendRequest" using a queued connection. + * It's used to return to the event loop before invoking sendRequest when + * there's a very real chance that the request could have been aborted + * (i.e. after having emitted 'encrypted'). + */ +void QHttpNetworkConnectionChannel::sendRequestDelayed() +{ + QMetaObject::invokeMethod(this, [this] { + Q_ASSERT(!protocolHandler.isNull()); + if (reply) + protocolHandler->sendRequest(); + }, Qt::ConnectionType::QueuedConnection); +} void QHttpNetworkConnectionChannel::_q_receiveReply() { @@ -1234,7 +1248,7 @@ void QHttpNetworkConnectionChannel::_q_encrypted() emit reply->encrypted(); } if (reply) - sendRequest(); + sendRequestDelayed(); } } |