Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
None
-
5.12.3
-
None
-
Linux 4.15.0-62-generic Ubuntu 18.04.3 x86_64
Description
Hello there!
It looks like a bug to me , but maybe I'm wrong and its indeed a wanted functionallity.
So in my case I try to set a specific network configuration named "wlan0"(other then the QNetworkConfiguration::defaultConfiguration named "eth0") to a QNAM wich then should be used for all HTTP method calls like QNetworkAccessManager::get, post, put etc
QNetworkConfigurationManager config_manager; QList<QNetworkConfiguration> configs = config_manager.allConfigurations(); for(const QNetworkConfiguration &config: configs) { if (config.name() == QStringLiteral("wlan0") && config.isValid() && config.state() == QNetworkConfiguration::Active) { m_pManager->setConfiguration(config); break; } }
The "wlan0" configuration is valid and active, but the QNetworkConfiguration::defaultConfiguration will be still used by QNAM.
I debugged the qt sources and found this piece of code (Qt/5.12.3/Src/qtbase/src/network/access/qnetworkaccessmanager.cpp:1420), which looks like a bug to me:
if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.identifier().isEmpty())) { if (!d->networkConfiguration.identifier().isEmpty()) { if ((d->networkConfiguration.state() & QNetworkConfiguration::Defined) && d->networkConfiguration != d->networkConfigurationManager.defaultConfiguration()) d->createSession(d->networkConfigurationManager.defaultConfiguration()); else d->createSession(d->networkConfiguration); } .... }
When I do read the code right, it should be exactly the opposite :
if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.identifier().isEmpty())) { if (!d->networkConfiguration.identifier().isEmpty()) { if ((d->networkConfiguration.state() & QNetworkConfiguration::Defined) && d->networkConfiguration != d->networkConfigurationManager.defaultConfiguration()) d->createSession(d->networkConfiguration); else d->createSession(d->networkConfigurationManager.defaultConfiguration()); } .... }