QNetworkStatusMonitor - make it always enabled on Darwin

Also undo changes in setNetworkAccessible and setConfiguration
since they introduced a change in behavior, which results
in auto-test failing.

Change-Id: I5d74c47338bff8f964ba2e27256902c79303e00f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Timur Pocheptsov 2019-05-06 14:29:11 +02:00
parent 681bd76e67
commit 8ac77123e2
2 changed files with 5 additions and 28 deletions

View File

@ -1039,13 +1039,10 @@ QNetworkReply *QNetworkAccessManager::deleteResource(const QNetworkRequest &requ
void QNetworkAccessManager::setConfiguration(const QNetworkConfiguration &config)
{
Q_D(QNetworkAccessManager);
if (!d->statusMonitor.isEnabled()) {
d->networkConfiguration = config;
d->customNetworkConfiguration = true;
d->createSession(config);
} else {
qWarning(lcNetMon, "No network configuration can be set with network status monitor enabled");
}
d->networkConfiguration = config;
d->customNetworkConfiguration = true;
d->createSession(config);
}
/*!
@ -1107,11 +1104,6 @@ void QNetworkAccessManager::setNetworkAccessible(QNetworkAccessManager::NetworkA
{
Q_D(QNetworkAccessManager);
if (d->statusMonitor.isEnabled()) {
qWarning(lcNetMon, "Can not manually set network accessibility with the network status monitor enabled");
return;
}
d->defaultAccessControl = accessible == NotAccessible ? false : true;
if (d->networkAccessible != accessible) {

View File

@ -48,7 +48,6 @@
#include <netinet/in.h>
#include <cstring>
#include <mutex>
QT_BEGIN_NAMESPACE
@ -309,20 +308,8 @@ public:
bool isOnlineIpv4 = false;
QNetworkConnectionMonitor ipv6Probe;
bool isOnlineIpv6 = false;
static bool enabled;
static void readEnv();
};
bool QNetworkStatusMonitorPrivate::enabled = false;
void QNetworkStatusMonitorPrivate::readEnv()
{
bool envOk = false;
const int env = qEnvironmentVariableIntValue("QT_USE_NETWORK_MONITOR", &envOk);
enabled = envOk && env > 0;
}
QNetworkStatusMonitor::QNetworkStatusMonitor()
: QObject(*new QNetworkStatusMonitorPrivate)
{
@ -400,9 +387,7 @@ bool QNetworkStatusMonitor::isNetworkAccesible()
bool QNetworkStatusMonitor::isEnabled()
{
static std::once_flag envRead = {};
std::call_once(envRead, QNetworkStatusMonitorPrivate::readEnv);
return QNetworkStatusMonitorPrivate::enabled;
return true;
}
void QNetworkStatusMonitor::reachabilityChanged(bool online)