mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Wi-Fi: Fixes to prevent segfault when only one network is detected and connected
This commit is contained in:
parent
f9a1fe6931
commit
0b4d8138da
3 changed files with 59 additions and 41 deletions
|
@ -36,7 +36,7 @@ localLibraryWidget::localLibraryWidget(QWidget *parent) :
|
|||
}
|
||||
|
||||
if(global::deviceID == "n705\n") {
|
||||
bookTitleTruncateThreshold = 30;
|
||||
bookTitleTruncateThreshold = 27;
|
||||
}
|
||||
else if(global::deviceID == "n873\n") {
|
||||
bookTitleTruncateThreshold = 45;
|
||||
|
@ -57,7 +57,11 @@ localLibraryWidget::localLibraryWidget(QWidget *parent) :
|
|||
sW = QGuiApplication::screens()[0]->size().width();
|
||||
sH = QGuiApplication::screens()[0]->size().height();
|
||||
|
||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
||||
if(global::deviceID == "n705\n") {
|
||||
stdIconWidthDivider = 7.2;
|
||||
stdIconHeightDivider = 7.2;
|
||||
}
|
||||
else if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
||||
stdIconWidthDivider = 9.5;
|
||||
stdIconHeightDivider = 9.5;
|
||||
}
|
||||
|
|
|
@ -191,8 +191,15 @@ libraryWidget::~libraryWidget()
|
|||
void libraryWidget::setupView() {
|
||||
ui->booksStackedWidget->show();
|
||||
|
||||
stdIconWidth = sW / 5.5;
|
||||
stdIconHeight = sH / 5.5;
|
||||
if(global::deviceID == "n705\n") {
|
||||
stdIconWidth = sW / 7
|
||||
;
|
||||
stdIconHeight = sH / 7;
|
||||
}
|
||||
else {
|
||||
stdIconWidth = sW / 5.5;
|
||||
stdIconHeight = sH / 5.5;
|
||||
}
|
||||
|
||||
ui->book1Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/1/title"));
|
||||
ui->book2Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/2/title"));
|
||||
|
|
|
@ -248,46 +248,49 @@ void wifiDialog::refreshNetworksList() {
|
|||
}
|
||||
}
|
||||
|
||||
// Sort based on signal strength
|
||||
QVector<global::wifi::wifiNetworkData> sortedPureNetworkList;
|
||||
sortedPureNetworkList.append(pureNetworkList.first());
|
||||
pureNetworkList.removeFirst();
|
||||
// Possible fix for a segmentation 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;
|
||||
log(QString::number(pureNetworkList.count()));
|
||||
if(pureNetworkList.count() >= 1) {
|
||||
// Sort based on signal strength
|
||||
QVector<global::wifi::wifiNetworkData> sortedPureNetworkList;
|
||||
sortedPureNetworkList.append(pureNetworkList.first());
|
||||
pureNetworkList.removeFirst();
|
||||
// Possible fix for a segmentation 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);
|
||||
log("There are " + QString::number(sortedPureNetworkList.count()) + " sorted networks", className);
|
||||
|
||||
for(global::wifi::wifiNetworkData wifiNetwork: sortedPureNetworkList) {
|
||||
log("Signal strength with sorting: " + QString::number(wifiNetwork.signal), className);
|
||||
}
|
||||
for(global::wifi::wifiNetworkData wifiNetwork: sortedPureNetworkList) {
|
||||
log("Signal strength with sorting: " + QString::number(wifiNetwork.signal), className);
|
||||
}
|
||||
|
||||
// And now, handle the remainder of the networks
|
||||
for(global::wifi::wifiNetworkData wifiNetwork: sortedPureNetworkList) {
|
||||
network* connectedNetwork = new network;
|
||||
connectedNetwork->mainData = wifiNetwork;
|
||||
connectedNetwork->currentlyConnectedNetwork = currentNetwork;
|
||||
connectedNetwork->applyVariables();
|
||||
connect(this, &wifiDialog::killNetworkWidgets, connectedNetwork, &network::closeWrapper);
|
||||
connect(connectedNetwork, &network::showToastSignal, this, &wifiDialog::showToastSlot);
|
||||
connect(connectedNetwork, &network::refreshScreenSignal, this, &wifiDialog::refreshScreenSlot);
|
||||
ui->scrollBarLayout->addWidget(connectedNetwork, Qt::AlignTop);
|
||||
// And now, handle the remainder of the networks
|
||||
for(global::wifi::wifiNetworkData wifiNetwork: sortedPureNetworkList) {
|
||||
network* connectedNetwork = new network;
|
||||
connectedNetwork->mainData = wifiNetwork;
|
||||
connectedNetwork->currentlyConnectedNetwork = currentNetwork;
|
||||
connectedNetwork->applyVariables();
|
||||
connect(this, &wifiDialog::killNetworkWidgets, connectedNetwork, &network::closeWrapper);
|
||||
connect(connectedNetwork, &network::showToastSignal, this, &wifiDialog::showToastSlot);
|
||||
connect(connectedNetwork, &network::refreshScreenSignal, this, &wifiDialog::refreshScreenSlot);
|
||||
ui->scrollBarLayout->addWidget(connectedNetwork, Qt::AlignTop);
|
||||
}
|
||||
}
|
||||
scannedAtLeastOnce = true;
|
||||
ui->refreshBtn->setEnabled(true);
|
||||
|
@ -296,7 +299,6 @@ void wifiDialog::refreshNetworksList() {
|
|||
secondScanTry = false;
|
||||
}
|
||||
|
||||
|
||||
void wifiDialog::on_wifiCheckBox_stateChanged(int arg1)
|
||||
{
|
||||
if(ignoreCheckBoxCall == false) {
|
||||
|
@ -319,7 +321,7 @@ void wifiDialog::on_wifiCheckBox_stateChanged(int arg1)
|
|||
}
|
||||
emit killNetworkWidgets();
|
||||
}
|
||||
if(wifiButtonEnabled == false){
|
||||
if(wifiButtonEnabled == false) {
|
||||
wifiButtonEnabled = true;
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +396,12 @@ void wifiDialog::watcher() {
|
|||
}
|
||||
|
||||
if(changing == true) {
|
||||
setStatusText("Disconnecting from a network or cleaning up");
|
||||
if(global::deviceID == "n705\n") {
|
||||
setStatusText("Disconnecting or cleaning up");
|
||||
}
|
||||
else {
|
||||
setStatusText("Disconnecting from a network or cleaning up");
|
||||
}
|
||||
log("prepare_changing_wifi.sh is active", className);
|
||||
QTimer::singleShot(relaunchMs, this, SLOT(watcher()));
|
||||
return void();
|
||||
|
|
Loading…
Reference in a new issue