QNetworkReplyHttpImpl - check 'isOpen' twice

A signal emitted after the first 'isOpen' check on QNetworkReply can
trigger a slot that aborts/closes our reply. So before we can append
any data to reply's buffer, we have to re-check that we're still open.

Task-number: QTBUG-59909
Change-Id: I781d5a4fd5fc30d485af63f45cf36c254378af64
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
bb10
Timur Pocheptsov 2017-04-05 15:35:38 +02:00
parent 59d9ee0aa4
commit 254f35ce98
1 changed files with 6 additions and 0 deletions

View File

@ -1883,6 +1883,12 @@ void QNetworkReplyHttpImplPrivate::_q_cacheLoadReadyRead()
totalSize.isNull() ? Q_INT64_C(-1) : totalSize.toLongLong());
}
}
// A signal we've emitted might be handled by a slot that aborts,
// so we need to check for that and bail out if it's happened:
if (!q->isOpen())
return;
// If there are still bytes available in the cacheLoadDevice then the user did not read
// in response to the readyRead() signal. This means we have to load from the cacheLoadDevice
// and buffer that stuff. This is needed to be able to properly emit finished() later.