From af279b34a8ecccd7dfa0d59b718bc3cf65ebce65 Mon Sep 17 00:00:00 2001 From: Lorn Potter <lorn.potter@gmail.com> Date: Mon, 27 Oct 2014 19:26:47 +1000 Subject: [PATCH] Reset QNAM's NetworkConfiguration when state changes. Since QNAM is initialized with defaultConfiguration, we need to reset the internal configuration used to the current defaultConfiguration when the state changes and a new configuration becomes the default. Task-number: QTBUG-40234 Change-Id: I50f23c62804f29370915eecac2c92301c5f3ead2 Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com> --- src/network/access/qnetworkaccessmanager.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index f00b58a8ce7..52d56fb0716 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -1135,7 +1135,12 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.identifier().isEmpty())) { QNetworkConfigurationManager manager; if (!d->networkConfiguration.identifier().isEmpty()) { - d->createSession(d->networkConfiguration); + if ((d->networkConfiguration.state() & QNetworkConfiguration::Defined) + && d->networkConfiguration != manager.defaultConfiguration()) + d->createSession(manager.defaultConfiguration()); + else + d->createSession(d->networkConfiguration); + } else { if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) d->createSession(manager.defaultConfiguration()); @@ -1590,6 +1595,11 @@ void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline) if (customNetworkConfiguration) { online = (networkConfiguration.state() & QNetworkConfiguration::Active); } else { + if (isOnline && online != isOnline) { + networkSessionStrongRef.clear(); + networkSessionWeakRef.clear(); + } + online = isOnline; } } -- GitLab