From f670e483c15c8b27db2bf40eadce86d3f735dc46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 22 Oct 2021 09:47:38 +0200 Subject: [PATCH] QNI: refactor to avoid tiny lambda slot objects by just adding the parameter to the signal there's no longer a need for the tiny lambdas that just call a getter. Originally the idea was that, since the emission from Backend to the 'frontend' may be a queued emission, I wanted to use the getter so that the data emitted from the frontend was as up-to-date as possible. But on one hand, that's not really a big problem, and at the same time it would then emit the signal twice with the same value. Change-Id: Ief0959f8cbf06faf1b02a1ed4ae777181ff4f059 Reviewed-by: Edward Welbourne --- src/network/kernel/qnetworkinformation.cpp | 9 ++++----- src/network/kernel/qnetworkinformation_p.h | 12 ++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/network/kernel/qnetworkinformation.cpp b/src/network/kernel/qnetworkinformation.cpp index 4f0b1405ef..3bfe623885 100644 --- a/src/network/kernel/qnetworkinformation.cpp +++ b/src/network/kernel/qnetworkinformation.cpp @@ -511,12 +511,11 @@ QNetworkInformation::QNetworkInformation(QNetworkInformationBackend *backend) : QObject(*(new QNetworkInformationPrivate(backend))) { connect(backend, &QNetworkInformationBackend::reachabilityChanged, this, - [this]() { emit reachabilityChanged(d_func()->backend->reachability()); }); - connect(backend, &QNetworkInformationBackend::behindCaptivePortalChanged, this, [this]() { - emit isBehindCaptivePortalChanged(d_func()->backend->behindCaptivePortal()); - }); + &QNetworkInformation::reachabilityChanged); + connect(backend, &QNetworkInformationBackend::behindCaptivePortalChanged, this, + &QNetworkInformation::isBehindCaptivePortalChanged); connect(backend, &QNetworkInformationBackend::transportMediumChanged, this, - [this]() { emit transportMediumChanged(d_func()->backend->transportMedium()); }); + &QNetworkInformation::transportMediumChanged); } /*! diff --git a/src/network/kernel/qnetworkinformation_p.h b/src/network/kernel/qnetworkinformation_p.h index 971340b6e3..3493de3b44 100644 --- a/src/network/kernel/qnetworkinformation_p.h +++ b/src/network/kernel/qnetworkinformation_p.h @@ -89,16 +89,16 @@ public: TransportMedium transportMedium() const { return m_transportMedium; } Q_SIGNALS: - void reachabilityChanged(); - void behindCaptivePortalChanged(); - void transportMediumChanged(); + void reachabilityChanged(Reachability reachability); + void behindCaptivePortalChanged(bool behindPortal); + void transportMediumChanged(TransportMedium medium); protected: void setReachability(QNetworkInformation::Reachability reachability) { if (m_reachability != reachability) { m_reachability = reachability; - emit reachabilityChanged(); + emit reachabilityChanged(reachability); } } @@ -106,7 +106,7 @@ protected: { if (m_behindCaptivePortal != behindPortal) { m_behindCaptivePortal = behindPortal; - emit behindCaptivePortalChanged(); + emit behindCaptivePortalChanged(behindPortal); } } @@ -114,7 +114,7 @@ protected: { if (m_transportMedium != medium) { m_transportMedium = medium; - emit transportMediumChanged(); + emit transportMediumChanged(medium); } }