Skip to content

Commit

Permalink
Ensure stateChanged signal connect matches disconnect
Browse files Browse the repository at this point in the history
A change to the connect signal introduced a lambda function, rather than
calling stateChanged directly, so that the disconnect no longer matched
the connect. This potentially prevented the disconnect from being
applied correctly.

This change matches the connect and disconnect up again.
  • Loading branch information
llewelld committed Jun 28, 2019
1 parent 20a249c commit fcd0c68
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/network/access/qnetworkaccessmanager.cpp
Expand Up @@ -1616,11 +1616,8 @@ void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &co
QObject::connect(networkSessionStrongRef.data(), SIGNAL(opened()), q, SIGNAL(networkSessionConnected()), Qt::QueuedConnection);
//QueuedConnection is used to avoid deleting the networkSession inside its closed signal
QObject::connect(networkSessionStrongRef.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()), Qt::QueuedConnection);
QObject::connect(networkSessionStrongRef.data(), &QNetworkSession::stateChanged,
q, [this](QNetworkSession::State s) {
qCDebug(lcNetworkAccess) << "QNAM: network session state changed:" << s;
_q_networkSessionStateChanged(s);
}, Qt::QueuedConnection);
QObject::connect(networkSessionStrongRef.data(), SIGNAL(stateChanged(QNetworkSession::State)),
q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)), Qt::QueuedConnection);
QObject::connect(networkSessionStrongRef.data(), SIGNAL(error(QNetworkSession::SessionError)),
q, SLOT(_q_networkSessionFailed(QNetworkSession::SessionError)));

Expand Down Expand Up @@ -1652,6 +1649,7 @@ void QNetworkAccessManagerPrivate::_q_networkSessionClosed()
void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession::State state)
{
Q_Q(QNetworkAccessManager);
qCDebug(lcNetworkAccess) << "QNAM: network session state changed:" << state;

if ((state == QNetworkSession::Connecting) && (!getNetworkSession())) {
qCWarning(lcNetworkAccess) << "QNAM: ignoring Connecting state received after the session closed";
Expand Down

0 comments on commit fcd0c68

Please sign in to comment.