From 3b8d4f3d89dd7f50161d280a7d8b947b60af73c2 Mon Sep 17 00:00:00 2001 From: Martchus Date: Fri, 16 Feb 2024 20:03:51 +0100 Subject: [PATCH] Fix crash when network information cannot be loaded --- syncthingwidgets/misc/syncthinglauncher.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/syncthingwidgets/misc/syncthinglauncher.cpp b/syncthingwidgets/misc/syncthinglauncher.cpp index 01dbc49..7970a2a 100644 --- a/syncthingwidgets/misc/syncthinglauncher.cpp +++ b/syncthingwidgets/misc/syncthinglauncher.cpp @@ -61,7 +61,8 @@ SyncthingLauncher::SyncthingLauncher(QObject *parent) // initialize handling of metered connections #ifdef SYNCTHINGCONNECTION_SUPPORT_METERED QNetworkInformation::loadBackendByFeatures(QNetworkInformation::Feature::Metered); - if (const auto *const networkInformation = QNetworkInformation::instance(); networkInformation->supports(QNetworkInformation::Feature::Metered)) { + if (const auto *const networkInformation = QNetworkInformation::instance(); + networkInformation && networkInformation->supports(QNetworkInformation::Feature::Metered)) { connect(networkInformation, &QNetworkInformation::isMeteredChanged, this, [this](bool isMetered) { setNetworkConnectionMetered(isMetered); }); setNetworkConnectionMetered(networkInformation->isMetered()); }