QNAM/QNetConMon: Update handling of QNetworkConnectionMonitor::start
QNetworkConnectionMonitor::start was previously called after checking d->networkAccessible, unfortunately that means if the network was unavailable when QNetworkConnectionMonitor was created we don't subscribe to updates or recheck the status (unless QNetworkAccessManager::networkAccessible() is called). Move the call to start to before the offline check. Also update the Windows backend so that it updates networkAccessible on the call to start() Pick-to: 5.15 Change-Id: I37647f19f703947143e7cbdafe09619ce0d98cc1 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
ebc3350be7
commit
382577419a
@ -1248,10 +1248,14 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
|
||||
}
|
||||
|
||||
if (d->statusMonitor.isEnabled()) {
|
||||
if (!d->statusMonitor.isMonitoring() && !d->statusMonitor.start())
|
||||
qWarning(lcNetMon, "failed to start network status monitoring");
|
||||
|
||||
// See the code in ctor - QNetworkStatusMonitor allows us to
|
||||
// immediately set 'networkAccessible' even before we start
|
||||
// the monitor.
|
||||
if (!d->networkAccessible && !isLocalFile) {
|
||||
// the monitor. If the monitor is unable to monitor then let's
|
||||
// assume there's something wrong with the monitor and keep going.
|
||||
if (d->statusMonitor.isMonitoring() && !d->networkAccessible && !isLocalFile) {
|
||||
QHostAddress dest;
|
||||
QString host = req.url().host().toLower();
|
||||
if (!(dest.setAddress(host) && dest.isLoopback())
|
||||
@ -1260,9 +1264,6 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
|
||||
return new QDisabledNetworkReply(this, req, op);
|
||||
}
|
||||
}
|
||||
|
||||
if (!d->statusMonitor.isMonitoring() && !d->statusMonitor.start())
|
||||
qWarning(lcNetMon, "failed to start network status monitoring");
|
||||
}
|
||||
#endif
|
||||
QNetworkRequest request = req;
|
||||
|
@ -618,6 +618,14 @@ bool QNetworkListManagerEvents::start()
|
||||
<< errorStringFromHResult(hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update connectivity since it might have changed since this class was constructed
|
||||
NLM_CONNECTIVITY connectivity;
|
||||
hr = networkListManager->GetConnectivity(&connectivity);
|
||||
if (FAILED(hr))
|
||||
qCWarning(lcNetMon) << "Could not get connectivity:" << errorStringFromHResult(hr);
|
||||
else
|
||||
monitor->setConnectivity(connectivity);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user