From f21857fad90c990f16830b920298b4b7ee3afe30 Mon Sep 17 00:00:00 2001 From: Szybet <53944559+Szybet@users.noreply.github.com> Date: Sun, 28 Aug 2022 17:58:22 +0200 Subject: [PATCH] fix for only one network scanned and for closing wifi logger --- src/widgets/dialogs/wifi/wifidialog.cpp | 32 ++++++++++++++----------- src/widgets/dialogs/wifi/wifilogger.cpp | 6 ++--- src/widgets/dialogs/wifi/wifilogger.h | 1 + 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/widgets/dialogs/wifi/wifidialog.cpp b/src/widgets/dialogs/wifi/wifidialog.cpp index df25b1a..8fdc5b8 100644 --- a/src/widgets/dialogs/wifi/wifidialog.cpp +++ b/src/widgets/dialogs/wifi/wifidialog.cpp @@ -252,21 +252,24 @@ void wifiDialog::refreshNetworksList() { QVector sortedPureNetworkList; sortedPureNetworkList.append(pureNetworkList.first()); pureNetworkList.removeFirst(); - for(global::wifi::wifiNetworkData wifiNetwork: pureNetworkList) { - bool stopIterating = false; - int counter = 0; - for(global::wifi::wifiNetworkData wifiNetworkToSort: sortedPureNetworkList) { - if(stopIterating == false) { - if(wifiNetwork.signal >= wifiNetworkToSort.signal) { - sortedPureNetworkList.insert(counter, wifiNetwork); - stopIterating = true; + // Possible fix for a segment fault + if(pureNetworkList.isEmpty() == false) { + for(global::wifi::wifiNetworkData wifiNetwork: pureNetworkList) { + bool stopIterating = false; + int counter = 0; + for(global::wifi::wifiNetworkData wifiNetworkToSort: sortedPureNetworkList) { + if(stopIterating == false) { + if(wifiNetwork.signal >= wifiNetworkToSort.signal) { + sortedPureNetworkList.insert(counter, wifiNetwork); + stopIterating = true; + } + counter = counter + 1; } - counter = counter + 1; } - } - // This happens if it's the smallest value, so insert it at the end - if(stopIterating == false) { - sortedPureNetworkList.append(wifiNetwork); + // This happens if it's the smallest value, so insert it at the end + if(stopIterating == false) { + sortedPureNetworkList.append(wifiNetwork); + } } } log("There are " + QString::number(sortedPureNetworkList.count()) + " sorted networks", className); @@ -438,7 +441,8 @@ void wifiDialog::watcher() { bool time = checkProcessName("smarter_time_sync.sh"); if(time == true) { forceRefresh = true; - setStatusText("Syncing"); + // Please leave it as "Syncting time" because many people will complain about innacurate time. This info will answer them + setStatusText("Syncing time"); QTimer::singleShot(relaunchMs, this, SLOT(watcher())); return void(); } diff --git a/src/widgets/dialogs/wifi/wifilogger.cpp b/src/widgets/dialogs/wifi/wifilogger.cpp index 51682c1..1b59149 100644 --- a/src/widgets/dialogs/wifi/wifilogger.cpp +++ b/src/widgets/dialogs/wifi/wifilogger.cpp @@ -64,7 +64,7 @@ wifilogger::~wifilogger() void wifilogger::setWifiInfoPage() { if(checkWifiState() == global::wifi::wifiState::configured) { - QTimer::singleShot(0, this, SLOT(getWifiInformation())); + getWifiInformationTimer.singleShot(0, this, SLOT(getWifiInformation())); ui->stackedWidget->setCurrentIndex(0); ui->nameLabel->setText("Network information"); } @@ -128,7 +128,6 @@ void wifilogger::getWifiInformation() { QFile wifiInformationPath = QFile("/external_root/run/wifi_information"); if(waitingForFile == false) { wifiInformationPath.remove(); - log("Sending get_wifi_information ibxd call", className); string_writeconfig("/opt/ibxd", "get_wifi_information\n"); waitingForFile = true; @@ -136,7 +135,7 @@ void wifilogger::getWifiInformation() { if(waitingForFile == true) { if(wifiInformationPath.exists() == false) { - QTimer::singleShot(1000, this, SLOT(getWifiInformation())); + getWifiInformationTimer.singleShot(1000, this, SLOT(getWifiInformation())); return void(); } } @@ -179,6 +178,7 @@ void wifilogger::getWifiInformation() { void wifilogger::on_returnBtn_clicked() { log("Exiting wifilogger", className); + getWifiInformationTimer.stop(); this->deleteLater(); this->close(); } diff --git a/src/widgets/dialogs/wifi/wifilogger.h b/src/widgets/dialogs/wifi/wifilogger.h index c7bcf39..e10bd92 100644 --- a/src/widgets/dialogs/wifi/wifilogger.h +++ b/src/widgets/dialogs/wifi/wifilogger.h @@ -31,6 +31,7 @@ private: QFile fancyLogs = QFile("/external_root/run/wifi_stats"); QFile allLogs = QFile("/external_root/var/log/wifi.log"); bool waitingForFile = false; + QTimer getWifiInformationTimer; private slots: void setWifiInfoPage();