fix:it will core,when vpn connects failed.

bug link:http://172.17.50.104/biz/bug-view-91112.html
This commit is contained in:
renpeijia 2021-11-16 15:53:20 +08:00
parent 30d93af9ca
commit 4633f0fcbc
3 changed files with 40 additions and 14 deletions

View File

@ -74,6 +74,11 @@ KyConnectItem *KyActiveConnectResourse::getActiveConnectionByUuid(QString connec
} }
QStringList interfaces = activeConnectPtr->devices(); QStringList interfaces = activeConnectPtr->devices();
if (interfaces.isEmpty()) {
qWarning()<< LOG_FLAG << "get active connection device failed.";
return nullptr;
}
QString ifaceUni = interfaces.at(0); QString ifaceUni = interfaces.at(0);
NetworkManager::Device:: Ptr devicePtr = NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni); m_networkResourceInstance->findDeviceUni(ifaceUni);
@ -565,23 +570,28 @@ void KyActiveConnectResourse::getApActivateConnect(QList<KyApConnectItem *> &apC
QString KyActiveConnectResourse::getDeviceOfActivateConnect(QString conUuid) QString KyActiveConnectResourse::getDeviceOfActivateConnect(QString conUuid)
{ {
QString deviceName = ""; QString deviceName = "";
NetworkManager::ActiveConnection::Ptr activeConnectPtr = NetworkManager::ActiveConnection::Ptr activeConnectPtr =
m_networkResourceInstance->getActiveConnect(conUuid); m_networkResourceInstance->getActiveConnect(conUuid);
if (nullptr == activeConnectPtr) { if (nullptr == activeConnectPtr) {
qWarning()<< "[KyActiveConnectResourse]" <<"it can not find connect "<< conUuid; qWarning()<< "[KyActiveConnectResourse]" <<"it can not find connect "<< conUuid;
return deviceName; return deviceName;
} }
QStringList interfaces = activeConnectPtr->devices(); QStringList interfaces = activeConnectPtr->devices();
QString ifaceUni = interfaces.at(0); if (interfaces.isEmpty()) {
NetworkManager::Device:: Ptr devicePtr = qWarning()<< LOG_FLAG << "get device of active connection failed.";
m_networkResourceInstance->findDeviceUni(ifaceUni); return deviceName;
deviceName = devicePtr->interfaceName(); }
return deviceName; QString ifaceUni = interfaces.at(0);
NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni);
deviceName = devicePtr->interfaceName();
return deviceName;
} }
bool KyActiveConnectResourse::connectionIsVirtual(QString uuid) bool KyActiveConnectResourse::connectionIsVirtual(QString uuid)
@ -595,6 +605,11 @@ bool KyActiveConnectResourse::connectionIsVirtual(QString uuid)
} }
QStringList interfaces = activeConnectPtr->devices(); QStringList interfaces = activeConnectPtr->devices();
if (interfaces.isEmpty()) {
qWarning()<< LOG_FLAG << "active connection get device failed.";
return false;
}
QString ifaceUni = interfaces.at(0); QString ifaceUni = interfaces.at(0);
NetworkManager::Device:: Ptr devicePtr = NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni); m_networkResourceInstance->findDeviceUni(ifaceUni);

View File

@ -167,6 +167,11 @@ QString KyWirelessNetResource::getActiveConnectSsidByDevice(QString deviceName)
} }
QStringList interfaces = activeConnectionPtr->devices(); QStringList interfaces = activeConnectionPtr->devices();
if(interfaces.isEmpty()) {
qWarning()<< LOG_FLAG <<"get active device failed.";
continue;
}
QString ifaceUni = interfaces.at(0); QString ifaceUni = interfaces.at(0);
NetworkManager::Device:: Ptr devicePtr = NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni); m_networkResourceInstance->findDeviceUni(ifaceUni);
@ -233,6 +238,10 @@ QString KyWirelessNetResource::getDeviceIFace(NetworkManager::ActiveConnection::
wirelessNetResourcessid = wireless_sett->ssid(); wirelessNetResourcessid = wireless_sett->ssid();
QStringList interfaces = actConn->devices(); QStringList interfaces = actConn->devices();
if (interfaces.isEmpty()) {
return "";
}
QString ifaceUni = interfaces.at(0); QString ifaceUni = interfaces.at(0);
NetworkManager::Device:: Ptr devicePtr = NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni); m_networkResourceInstance->findDeviceUni(ifaceUni);

View File

@ -968,12 +968,14 @@ void LanPage::updateConnectionProperty(KyConnectItem *p_connectItem)
} }
} }
} else { } else if (!m_activeConnectionMap.contains(newUuid)){
if (p_connectItem->m_ifaceName == m_currentDeviceName if (p_connectItem->m_ifaceName == m_currentDeviceName
|| p_connectItem->m_ifaceName.isEmpty()) { || p_connectItem->m_ifaceName.isEmpty()) {
QListWidgetItem *p_listWidgetItem = insertNewItem(p_connectItem, m_inactivatedLanListWidget); QListWidgetItem *p_listWidgetItem = insertNewItem(p_connectItem, m_inactivatedLanListWidget);
m_inactiveConnectionMap.insert(newUuid, p_listWidgetItem); m_inactiveConnectionMap.insert(newUuid, p_listWidgetItem);
} }
} else {
qWarning() << LOG_FLAG << newUuid <<" is in activemap, so not process.";
} }
return; return;