From e9063d168d34c5cd90a57fcae30cc465d87cf8c1 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Thu, 20 Jul 2023 12:58:50 +0300 Subject: [PATCH] LanLinkProvider: Restore previous network change behavior --- core/backends/lan/lanlinkprovider.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp index af0019107..2466fe6c2 100644 --- a/core/backends/lan/lanlinkprovider.cpp +++ b/core/backends/lan/lanlinkprovider.cpp @@ -71,13 +71,17 @@ LanLinkProvider::LanLinkProvider(bool testMode, quint16 udpBroadcastPort, quint1 } }); #else - // Detect when a network interface changes status, so we announce ourselves in the new network - QNetworkInformation::instance()->loadBackendByFeatures(QNetworkInformation::Feature::Reachability); - connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged, this, [this]() { + const auto checkNetworkChange = [this]() { if (QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online) { onNetworkChange(); } - }); + }; + // Detect when a network interface changes status, so we announce ourselves in the new network + QNetworkInformation::instance()->loadBackendByFeatures(QNetworkInformation::Feature::Reachability); + + // We want to know if our current network reachability has changed, or if we change from one network to another + connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged, this, checkNetworkChange); + connect(QNetworkInformation::instance(), &QNetworkInformation::transportMediumChanged, this, checkNetworkChange); #endif } @@ -187,7 +191,6 @@ void LanLinkProvider::broadcastUdpIdentityPacket() #endif } - QList LanLinkProvider::getBroadcastAddresses() { const QStringList customDevices = KdeConnectConfig::instance().customDevices();