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

View File

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