fix segmentation fault

This commit is contained in:
jzxc95 2021-08-26 10:37:18 +08:00
parent acfc47b604
commit 80a0f29235
2 changed files with 22 additions and 1 deletions

View File

@ -94,7 +94,7 @@ void KyWirelessNetResource::getWirelessActiveConnection(NetworkManager::ActiveCo
NetworkManager::ActiveConnection::List activeConnectionList; NetworkManager::ActiveConnection::List activeConnectionList;
activeConnectionList.clear(); activeConnectionList.clear();
activeConnectionList = m_networkResourceInstance->m_activeConns; activeConnectionList = m_networkResourceInstance->getActiveConnectList();
if (activeConnectionList.isEmpty()) { if (activeConnectionList.isEmpty()) {
return; return;
} }
@ -102,14 +102,23 @@ void KyWirelessNetResource::getWirelessActiveConnection(NetworkManager::ActiveCo
NetworkManager::ActiveConnection::Ptr activeConnectionPtr = nullptr; NetworkManager::ActiveConnection::Ptr activeConnectionPtr = nullptr;
for (; index < activeConnectionList.size(); index++) { for (; index < activeConnectionList.size(); index++) {
activeConnectionPtr = activeConnectionList.at(index); activeConnectionPtr = activeConnectionList.at(index);
if (activeConnectionPtr.isNull()) {
continue;
}
if (NetworkManager::ConnectionSettings::ConnectionType::Wireless != activeConnectionPtr->type()) { if (NetworkManager::ConnectionSettings::ConnectionType::Wireless != activeConnectionPtr->type()) {
continue; continue;
} }
if (state != activeConnectionPtr->state()) { if (state != activeConnectionPtr->state()) {
continue; continue;
} }
QString ssid; QString ssid;
QString ifaceName = getDeviceIFace(activeConnectionPtr,ssid); QString ifaceName = getDeviceIFace(activeConnectionPtr,ssid);
if(ifaceName.isEmpty() || ssid.isNull()) {
continue;
}
if (map.contains(ifaceName)) { if (map.contains(ifaceName)) {
map[ifaceName].append(ssid); map[ifaceName].append(ssid);
} else { } else {
@ -129,8 +138,19 @@ QString KyWirelessNetResource::getDeviceIFace(NetworkManager::ActiveConnection::
} }
NetworkManager::Connection::Ptr conn = actConn->connection(); NetworkManager::Connection::Ptr conn = actConn->connection();
if (conn.isNull()) {
return "";
}
NetworkManager::ConnectionSettings::Ptr sett = conn->settings(); NetworkManager::ConnectionSettings::Ptr sett = conn->settings();
if (sett.isNull()) {
return "";
}
NetworkManager::WirelessSetting::Ptr wireless_sett = sett->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>(); NetworkManager::WirelessSetting::Ptr wireless_sett = sett->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
if (wireless_sett.isNull()) {
return "";
}
wirelessNetResourcessid = wireless_sett->ssid(); wirelessNetResourcessid = wireless_sett->ssid();
return sett->interfaceName(); return sett->interfaceName();

View File

@ -3,6 +3,7 @@
LanPage::LanPage(QWidget *parent) : TabPage(parent) LanPage::LanPage(QWidget *parent) : TabPage(parent)
{ {
m_device = new KyNetworkDeviceResourse(this);
initDevice(); initDevice();
initLanUI(); initLanUI();
} }