summaryrefslogtreecommitdiffstats
path: root/src/network/kernel
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2021-10-22 09:47:38 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2021-10-26 18:28:04 +0200
commitf670e483c15c8b27db2bf40eadce86d3f735dc46 (patch)
treed9194cc4505174d084050ac365722f3c8914cdc9 /src/network/kernel
parentbb220f2d99261eaa7c5021988a9443735ed2a93d (diff)
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 <edward.welbourne@qt.io>
Diffstat (limited to 'src/network/kernel')
-rw-r--r--src/network/kernel/qnetworkinformation.cpp9
-rw-r--r--src/network/kernel/qnetworkinformation_p.h12
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);
}
}