QNetworkInformation: Remove the default argument
And the code for loading whatever backend is sorted first. Though, looking at the code it would've never returned 'true' anyway. Pick-to: 6.1 6.1.0 Change-Id: I7bc2c740e8cb5343e5843cb1d65715d236b92a25 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
ffd13e19a9
commit
b67fe6dc7d
@ -166,6 +166,8 @@ QStringList QNetworkInformationPrivate::backendNames()
|
|||||||
|
|
||||||
QNetworkInformation *QNetworkInformationPrivate::create(QStringView name)
|
QNetworkInformation *QNetworkInformationPrivate::create(QStringView name)
|
||||||
{
|
{
|
||||||
|
if (name.isEmpty())
|
||||||
|
return nullptr;
|
||||||
if (!dataHolder())
|
if (!dataHolder())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#ifdef DEBUG_LOADING
|
#ifdef DEBUG_LOADING
|
||||||
@ -184,40 +186,31 @@ QNetworkInformation *QNetworkInformationPrivate::create(QStringView name)
|
|||||||
return dataHolder->instanceHolder.get();
|
return dataHolder->instanceHolder.get();
|
||||||
|
|
||||||
|
|
||||||
QNetworkInformationBackend *backend = nullptr;
|
const auto nameMatches = [name](QNetworkInformationBackendFactory *factory) {
|
||||||
if (!name.isEmpty()) {
|
return factory->name().compare(name, Qt::CaseInsensitive) == 0;
|
||||||
const auto nameMatches = [name](QNetworkInformationBackendFactory *factory) {
|
};
|
||||||
return factory->name().compare(name, Qt::CaseInsensitive) == 0;
|
auto it = std::find_if(dataHolder->factories.cbegin(), dataHolder->factories.cend(),
|
||||||
};
|
nameMatches);
|
||||||
auto it = std::find_if(dataHolder->factories.cbegin(), dataHolder->factories.cend(),
|
if (it == dataHolder->factories.cend()) {
|
||||||
nameMatches);
|
|
||||||
if (it == dataHolder->factories.cend()) {
|
|
||||||
#ifdef DEBUG_LOADING
|
#ifdef DEBUG_LOADING
|
||||||
if (dataHolder->factories.isEmpty()) {
|
if (dataHolder->factories.isEmpty()) {
|
||||||
qDebug("No plugins available");
|
qDebug("No plugins available");
|
||||||
} else {
|
} else {
|
||||||
QString listNames;
|
QString listNames;
|
||||||
listNames.reserve(8 * dataHolder->factories.count());
|
listNames.reserve(8 * dataHolder->factories.count());
|
||||||
for (const auto *factory : qAsConst(dataHolder->factories))
|
for (const auto *factory : qAsConst(dataHolder->factories))
|
||||||
listNames += factory->name() + QStringLiteral(", ");
|
listNames += factory->name() + QStringLiteral(", ");
|
||||||
listNames.chop(2);
|
listNames.chop(2);
|
||||||
qDebug().nospace() << "Couldn't find " << name << " in list with names: { "
|
qDebug().nospace() << "Couldn't find " << name << " in list with names: { "
|
||||||
<< listNames << " }";
|
<< listNames << " }";
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_LOADING
|
|
||||||
qDebug() << "Creating instance using loader named " << (*it)->name();
|
|
||||||
#endif
|
#endif
|
||||||
backend = (*it)->create({});
|
return nullptr;
|
||||||
} else {
|
|
||||||
#ifdef DEBUG_LOADING
|
|
||||||
qDebug() << "Creating instance using loader named" << dataHolder->factories.front()->name();
|
|
||||||
#endif
|
|
||||||
if (!dataHolder->factories.isEmpty())
|
|
||||||
backend = dataHolder->factories.front()->create({});
|
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_LOADING
|
||||||
|
qDebug() << "Creating instance using loader named " << (*it)->name();
|
||||||
|
#endif
|
||||||
|
QNetworkInformationBackend *backend = (*it)->create({});
|
||||||
if (!backend)
|
if (!backend)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
dataHolder->instanceHolder.reset(new QNetworkInformation(backend));
|
dataHolder->instanceHolder.reset(new QNetworkInformation(backend));
|
||||||
|
@ -78,7 +78,7 @@ public:
|
|||||||
|
|
||||||
virtual bool supports(Features features) const;
|
virtual bool supports(Features features) const;
|
||||||
|
|
||||||
static bool load(QStringView backend = {});
|
static bool load(QStringView backend);
|
||||||
static bool load(Features features);
|
static bool load(Features features);
|
||||||
static QStringList availableBackends();
|
static QStringList availableBackends();
|
||||||
static QNetworkInformation *instance();
|
static QNetworkInformation *instance();
|
||||||
|
Loading…
Reference in New Issue
Block a user