Fix hang in qnam when disconnecting
Generate error for network requests when connection gets disconnected. Documentation states that QNAM requests will fail if network is not accessible, so we need to track session state. Task-number: QTBUG-47482 Change-Id: I2c2d348637f72b2a908b438a66aa543a878de1e5 Reviewed-by: Timo Jyrinki <timo.jyrinki@canonical.com> Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
parent
d05bb9ffb0
commit
1b29ef627c
@ -1676,6 +1676,11 @@ void QNetworkReplyHttpImplPrivate::_q_startOperation()
|
||||
Q_ARG(QString, QCoreApplication::translate("QNetworkReply", "backend start error.")));
|
||||
QMetaObject::invokeMethod(q, "_q_finished", synchronous ? Qt::DirectConnection : Qt::QueuedConnection);
|
||||
return;
|
||||
#endif
|
||||
} else {
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QObject::connect(session.data(), SIGNAL(stateChanged(QNetworkSession::State)),
|
||||
q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)), Qt::QueuedConnection);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1844,6 +1849,16 @@ void QNetworkReplyHttpImplPrivate::_q_networkSessionConnected()
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkReplyHttpImplPrivate::_q_networkSessionStateChanged(QNetworkSession::State sessionState)
|
||||
{
|
||||
if (sessionState == QNetworkSession::Disconnected
|
||||
&& (state != Idle || state != Reconnecting)) {
|
||||
error(QNetworkReplyImpl::NetworkSessionFailedError,
|
||||
QCoreApplication::translate("QNetworkReply", "Network session error."));
|
||||
finished();
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkReplyHttpImplPrivate::_q_networkSessionFailed()
|
||||
{
|
||||
// Abort waiting and working replies.
|
||||
|
@ -95,6 +95,7 @@ public:
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionConnected())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionFailed())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionStateChanged(QNetworkSession::State))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionUsagePoliciesChanged(QNetworkSession::UsagePolicies))
|
||||
#endif
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_finished())
|
||||
@ -170,6 +171,7 @@ public:
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
void _q_networkSessionConnected();
|
||||
void _q_networkSessionFailed();
|
||||
void _q_networkSessionStateChanged(QNetworkSession::State);
|
||||
void _q_networkSessionUsagePoliciesChanged(QNetworkSession::UsagePolicies);
|
||||
#endif
|
||||
void _q_finished();
|
||||
|
@ -126,6 +126,11 @@ void QNetworkReplyImplPrivate::_q_startOperation()
|
||||
finished();
|
||||
#endif
|
||||
return;
|
||||
} else {
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QObject::connect(session.data(), SIGNAL(stateChanged(QNetworkSession::State)),
|
||||
q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)), Qt::QueuedConnection);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
@ -310,6 +315,16 @@ void QNetworkReplyImplPrivate::_q_networkSessionConnected()
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkReplyImplPrivate::_q_networkSessionStateChanged(QNetworkSession::State sessionState)
|
||||
{
|
||||
if (sessionState == QNetworkSession::Disconnected
|
||||
&& (state != Idle || state != Reconnecting)) {
|
||||
error(QNetworkReplyImpl::NetworkSessionFailedError,
|
||||
QCoreApplication::translate("QNetworkReply", "Network session error."));
|
||||
finished();
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkReplyImplPrivate::_q_networkSessionFailed()
|
||||
{
|
||||
// Abort waiting and working replies.
|
||||
|
@ -89,6 +89,7 @@ public:
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionConnected())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionFailed())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionStateChanged(QNetworkSession::State))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionUsagePoliciesChanged(QNetworkSession::UsagePolicies))
|
||||
#endif
|
||||
|
||||
@ -124,6 +125,7 @@ public:
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
void _q_networkSessionConnected();
|
||||
void _q_networkSessionFailed();
|
||||
void _q_networkSessionStateChanged(QNetworkSession::State);
|
||||
void _q_networkSessionUsagePoliciesChanged(QNetworkSession::UsagePolicies);
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user