~QHttpNetworkConnectionPrivate - disconnect from socket's signals

We have a 'channel' object connected to a socket with Qt::DirectConnection.
QHttpNetworkConnectionPrivate in its dtor (note, it's a private object destroyed
after its 'q' - QHttpNetworkConnection - was destroyed) calls socket->close()
and this can end up in socket setting an error and emitting (for example, in
QSslSocket::transmit). The slot (QHttpNetworkConnectionChannel::_q_error) will
access the now-dead/non-existing connection then. So disconnect the channel
from the socket early, before closing the socket.

Task-number: QTBUG-54167
Change-Id: I3ed4ba4b00650c3a39e5c1f33aa786e47bfbbc57
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
bb10
Timur Pocheptsov 2016-11-28 16:02:26 +01:00 committed by Jani Heikkinen
parent 534c1ce76d
commit 4f959b6b30
1 changed files with 1 additions and 0 deletions

View File

@ -116,6 +116,7 @@ QHttpNetworkConnectionPrivate::~QHttpNetworkConnectionPrivate()
{
for (int i = 0; i < channelCount; ++i) {
if (channels[i].socket) {
QObject::disconnect(channels[i].socket, Q_NULLPTR, &channels[i], Q_NULLPTR);
channels[i].socket->close();
delete channels[i].socket;
}