Fix bug reconnect wifi looply when receive several auto-connect signal

This commit is contained in:
chenlelin 2021-03-25 10:09:11 +08:00
parent 3f83674ce2
commit 673f2b486c
2 changed files with 14 additions and 8 deletions

View File

@ -1694,7 +1694,9 @@ void MainWindow::getWifiListDone(QStringList slist)
QStringList targetWifiList = connectableWifiPriorityList(slist);
if (!targetWifiList.isEmpty()) {
QFuture < void > future1 = QtConcurrent::run([=](){
if (!isWifiReconnecting) {
isWifiReconnecting = true;
QFuture < void > future1 = QtConcurrent::run([=]() {
QString wifiSsid = objKyDBus->getWifiSsid(targetWifiList.at(0));
QString modityCmd = "nmcli connection modify \""+ wifiSsid + "\" " + "802-11-wireless.bssid " + targetWifiList.at(1);
system(modityCmd.toUtf8().data());
@ -1702,6 +1704,7 @@ void MainWindow::getWifiListDone(QStringList slist)
system(reconnectWifiCmd.toUtf8().data());
});
}
}
} else if (current_wifi_list_state == LOAD_WIFI_LIST) {
//qDebug() << "loadwifi的列表";
loadWifiListDone(slist);
@ -1709,8 +1712,8 @@ void MainWindow::getWifiListDone(QStringList slist)
} else {
//qDebug() << "updatewifi的列表";
updateWifiListDone(slist);
current_wifi_list_state = LOAD_WIFI_LIST;
}
current_wifi_list_state = LOAD_WIFI_LIST;
oldWifiSlist = slist;
}
@ -2977,6 +2980,8 @@ void MainWindow::toReconnectWifi()
//处理外界对网络的连接与断开
void MainWindow::onExternalConnectionChange(QString type, bool isConnUp)
{
isWifiReconnecting = false;
if ( (type == "802-11-wireless" || type == "wifi") && !isConnUp ){
QTimer::singleShot(2*1000, this, SLOT(onToResetValue() ));
}

View File

@ -184,6 +184,7 @@ public:
bool isWifiBeConnUp = false; //wifi是否是连接上
bool isToSetLanValue = true; //本次执行是否进行赋值
bool isToSetWifiValue = true; //本次执行是否进行赋值
bool isWifiReconnecting;
int addNumberForWifi = 0;
int m_priX;