From ef0efc360f6ac4a9e565fa30e261fcba7e9e508c Mon Sep 17 00:00:00 2001 From: Michael Prager Date: Fri, 4 Mar 2022 03:49:34 +0100 Subject: [PATCH] [Connectivity Report] Fixed crash if signalStrengths is empty. BUG: 449276 --- .../connectivity_reportplugin.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/connectivity-report/connectivity_reportplugin.cpp b/plugins/connectivity-report/connectivity_reportplugin.cpp index 5ed437044..74c70d453 100644 --- a/plugins/connectivity-report/connectivity_reportplugin.cpp +++ b/plugins/connectivity-report/connectivity_reportplugin.cpp @@ -41,17 +41,19 @@ bool ConnectivityReportPlugin::receivePacket(const NetworkPacket& np) { if (np.type() == PACKET_TYPE_CONNECTIVITY_REPORT) { auto subscriptions = np.get(QStringLiteral("signalStrengths"), QVariantMap()); - auto networkInfo = subscriptions.first().toMap(); + if (!subscriptions.isEmpty()) { + auto networkInfo = subscriptions.first().toMap(); - const auto oldCellularNetworkType = m_cellularNetworkType; - const auto oldNetworkStrength = m_cellularNetworkStrength; + const auto oldCellularNetworkType = m_cellularNetworkType; + const auto oldNetworkStrength = m_cellularNetworkStrength; - m_cellularNetworkType = networkInfo.value(QStringLiteral("networkType")).toString(); - m_cellularNetworkStrength = networkInfo.value(QStringLiteral("signalStrength")).toInt(); + m_cellularNetworkType = networkInfo.value(QStringLiteral("networkType")).toString(); + m_cellularNetworkStrength = networkInfo.value(QStringLiteral("signalStrength")).toInt(); - if (oldCellularNetworkType != m_cellularNetworkType || - oldNetworkStrength != m_cellularNetworkStrength) { - Q_EMIT refreshed(m_cellularNetworkType, m_cellularNetworkStrength); + if (oldCellularNetworkType != m_cellularNetworkType || + oldNetworkStrength != m_cellularNetworkStrength) { + Q_EMIT refreshed(m_cellularNetworkType, m_cellularNetworkStrength); + } } }