Commit 6bc094b2 authored by David Redondo's avatar David Redondo 🏎
Browse files

Select a fallback backend if the prior ones are not supported

This allows us falling back to something else if our preferred backend
is not supported at runtime.
parent 8de6ba60
......@@ -54,11 +54,20 @@ NetworkPlugin::NetworkPlugin(QObject *parent, const QVariantList &args)
d->allDevices = new AllDevicesObject(d->container);
using creationFunction = std::add_pointer_t<NetworkBackend *(NetworkPlugin *parent)>;
std::vector<creationFunction> backendFunctions;
d->backend = new NetworkManagerBackend(this);
backendFunctions.emplace_back([](NetworkPlugin *parent) -> NetworkBackend* {return new NetworkManagerBackend(parent);});
if (!d->backend || !d->backend->isSupported()) {
delete d->backend;
for (auto func : backendFunctions) {
auto backend = func(this);
if (backend->isSupported()) {
d->backend = backend;
delete backend;
if (!d->backend) {
qWarning() << "Unable to start backend, network information not available.";
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment