[Connectivity Report] Fixed crash if signalStrengths is empty.

BUG: 449276
This commit is contained in:
Michael Prager 2022-03-04 03:49:34 +01:00 committed by Albert Vaca Cintora
parent 19b8249ed1
commit ef0efc360f

View file

@ -41,17 +41,19 @@ bool ConnectivityReportPlugin::receivePacket(const NetworkPacket& np)
{ {
if (np.type() == PACKET_TYPE_CONNECTIVITY_REPORT) { if (np.type() == PACKET_TYPE_CONNECTIVITY_REPORT) {
auto subscriptions = np.get<QVariantMap>(QStringLiteral("signalStrengths"), QVariantMap()); auto subscriptions = np.get<QVariantMap>(QStringLiteral("signalStrengths"), QVariantMap());
auto networkInfo = subscriptions.first().toMap(); if (!subscriptions.isEmpty()) {
auto networkInfo = subscriptions.first().toMap();
const auto oldCellularNetworkType = m_cellularNetworkType; const auto oldCellularNetworkType = m_cellularNetworkType;
const auto oldNetworkStrength = m_cellularNetworkStrength; const auto oldNetworkStrength = m_cellularNetworkStrength;
m_cellularNetworkType = networkInfo.value(QStringLiteral("networkType")).toString(); m_cellularNetworkType = networkInfo.value(QStringLiteral("networkType")).toString();
m_cellularNetworkStrength = networkInfo.value(QStringLiteral("signalStrength")).toInt(); m_cellularNetworkStrength = networkInfo.value(QStringLiteral("signalStrength")).toInt();
if (oldCellularNetworkType != m_cellularNetworkType || if (oldCellularNetworkType != m_cellularNetworkType ||
oldNetworkStrength != m_cellularNetworkStrength) { oldNetworkStrength != m_cellularNetworkStrength) {
Q_EMIT refreshed(m_cellularNetworkType, m_cellularNetworkStrength); Q_EMIT refreshed(m_cellularNetworkType, m_cellularNetworkStrength);
}
} }
} }