From 1458d1b31d2df20e79db9e873d36986bc87074a2 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 20 Mar 2015 16:38:15 +0100 Subject: [PATCH] Use allConfigurations instead of onlineConfigurations in isOnline() We need it because otherwise code like QNetworkConfigurationManager ncm; qDebug() << "ONLINE" << ncm->isOnline(); may give the wrong value because the queued signals that have been just connected a few lines above may not have been processed yet Change-Id: I959db75ed17497ab91eeba2669ee2c8947244f00 Reviewed-by: Alex Blasche --- src/network/bearer/qnetworkconfigmanager_p.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index ef7ab51462..6bbea1683c 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -276,7 +276,9 @@ bool QNetworkConfigurationManagerPrivate::isOnline() const { QMutexLocker locker(&mutex); - return !onlineConfigurations.isEmpty(); + // We need allConfigurations since onlineConfigurations is filled with queued connections + // and thus is not always (more importantly just after creation) up to date + return !allConfigurations(QNetworkConfiguration::Active).isEmpty(); } QNetworkConfigurationManager::Capabilities QNetworkConfigurationManagerPrivate::capabilities() const