From 0c9f34d8d534e2eb9dd3457bde51b7f696512d94 Mon Sep 17 00:00:00 2001 From: chenlelin Date: Tue, 12 Jan 2021 09:36:32 +0800 Subject: [PATCH] Fix bug error occur when switch to wired interface if refreshing wifi list --- src/kylin-dbus-interface.cpp | 2 +- src/mainwindow.cpp | 24 ++++++++++++++++-------- src/mainwindow.h | 4 ++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/kylin-dbus-interface.cpp b/src/kylin-dbus-interface.cpp index e43891d3..2ca3a0d4 100644 --- a/src/kylin-dbus-interface.cpp +++ b/src/kylin-dbus-interface.cpp @@ -781,7 +781,7 @@ void KylinDBus::onConnectionRemoved(QDBusObjectPath objPath) syslog(LOG_DEBUG, "An old network was removed from configure directory."); qDebug()<<"An old network was removed from configure directory."; - if (mw->is_btnNetList_clicked == 1) { + if (mw->is_btnLanList_clicked == 1) { emit this->updateWiredList(0); //send this signal to update wired network list } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2dea4017..ffc7f360 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -158,12 +158,12 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) { if (obj == ui->btnNetList) { if (event->type() == QEvent::HoverEnter) { - if (!is_btnNetList_clicked) { + if (!is_btnLanList_clicked) { ui->lbNetListBG->setStyleSheet(btnBgHoverQss); } return true; } else if(event->type() == QEvent::HoverLeave) { - if (!is_btnNetList_clicked) { + if (!is_btnLanList_clicked) { ui->lbNetListBG->setStyleSheet(btnBgLeaveQss); } return true; @@ -637,7 +637,7 @@ void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) this->showNormal(); this->raise(); this->activateWindow(); - if (is_btnNetList_clicked == 1) { + if (is_btnLanList_clicked == 1) { onBtnNetListClicked(0); } if (!is_init_wifi_list && !is_connect_hide_wifi) { @@ -1187,7 +1187,7 @@ void MainWindow::onBtnWifiClicked(int flag) void MainWindow::onBtnNetListClicked(int flag) { - this->is_btnNetList_clicked = 1; + this->is_btnLanList_clicked = 1; this->is_btnWifiList_clicked = 0; ui->lbNetListBG->setStyleSheet(btnOnQss); @@ -1242,7 +1242,7 @@ void MainWindow::onBtnNetListClicked(int flag) void MainWindow::on_btnWifiList_clicked() { this->is_btnWifiList_clicked = 1; - this->is_btnNetList_clicked = 0; + this->is_btnLanList_clicked = 0; BackThread *bt = new BackThread(); IFace *iface = bt->execGetIface(); @@ -1345,6 +1345,10 @@ void MainWindow::on_btnWifiList_clicked() // 获取lan列表回调 void MainWindow::getLanListDone(QStringList slist) { + if (this->is_btnWifiList_clicked == 1) { + return; + } + //要求使用上一次获取到的列表 if (this->ksnm->isUseOldLanSlist) { slist = oldLanSlist; @@ -1562,6 +1566,10 @@ void MainWindow::getLanListDone(QStringList slist) // 获取wifi列表回调 void MainWindow::getWifiListDone(QStringList slist) { + if (this->is_btnLanList_clicked == 1) { + return; + } + qDebug()<<"debug: oldWifiSlist.size()="<is_btnNetList_clicked = 1; + this->is_btnLanList_clicked = 1; this->is_btnWifiList_clicked = 0; ui->lbNetListBG->setStyleSheet(btnOnQss); @@ -2508,7 +2516,7 @@ void MainWindow::disWifiDone() } void MainWindow::disWifiStateKeep() { - if (this->is_btnNetList_clicked == 1) { + if (this->is_btnLanList_clicked == 1) { btnWireless->setSwitchStatus(false); } if (this->is_btnWifiList_clicked== 1) { @@ -2651,7 +2659,7 @@ void MainWindow::on_setNetSpeed() if ( objNetSpeed->getCurrentDownloadRates(objKyDBus->dbusWiFiCardName.toUtf8().data(), &start_rcv_rates, &start_tx_rates) == -1) { start_rcv_rates = end_rcv_rates; } - } else if(is_btnNetList_clicked == 1) { + } else if(is_btnLanList_clicked == 1) { if ( objNetSpeed->getCurrentDownloadRates(currConnIfname.toUtf8().data(), &start_rcv_rates, &start_tx_rates) == -1) { start_tx_rates = end_tx_rates; } diff --git a/src/mainwindow.h b/src/mainwindow.h index 9d7a160f..887d0642 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -148,12 +148,12 @@ public: //状态设置,0为假,1为真 int is_update_wifi_list = 0; //是否是update wifi列表,而不是load wifi列表 int is_init_wifi_list = 0; //是否在启动软件时正在获取wifi的列表 - int is_btnNetList_clicked = 1; //是否处于有线网界面 + int is_btnLanList_clicked = 1; //是否处于有线网界面 int is_btnWifiList_clicked = 0; //是否处于无线网界面 int is_wireless_adapter_ready = 1; //主机是否插入无线网卡 int is_keep_wifi_turn_on_state = 1; //是否要执行wifi开关变为打开样式 int is_stop_check_net_state = 0; //是否要在进行其他操作时停止检查网络状态 - int is_connect_net_failed = 0; //刚才是否连接wifi失败 + int is_connect_net_failed = 0; //刚才是否连接网络失败 int is_fly_mode_on = 0; //是否已经打开飞行模式 int is_hot_sopt_on = 0; //是否已经打开热点 int is_connect_hide_wifi = 0; //是否正在连接隐藏wifi