From f2a0a2c30b257aa0fca5039f87aeadf247b8381d Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Mon, 16 Dec 2019 14:35:25 -0600 Subject: Qt UI: Handle failures better If we pop a modal box before disabling the notifier, we'll get multiple messages. When a user clicks OK on the second message, it will attempt to double-free, causing a segfault. Whoops. --- ui/qt5/netsimplewifipage.cc | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'ui/qt5/netsimplewifipage.cc') diff --git a/ui/qt5/netsimplewifipage.cc b/ui/qt5/netsimplewifipage.cc index 9df3d76..9b77295 100644 --- a/ui/qt5/netsimplewifipage.cc +++ b/ui/qt5/netsimplewifipage.cc @@ -281,6 +281,8 @@ void NetworkSimpleWirelessPage::associate() { } void NetworkSimpleWirelessPage::processAssociateMessage(int) { + QString error; + if(wpactrl_update(&control) < 0) { dialog->setLabelText(tr("Issue communicating with wireless subsystem.")); } else { @@ -301,25 +303,28 @@ void NetworkSimpleWirelessPage::processAssociateMessage(int) { associated = true; horizonWizard()->next(); } else if(msg.startsWith("CTRL-EVENT-ASSOC-REJECT")) { - dialog->hide(); - QMessageBox::critical(this, tr("Could Not Connect"), - tr("An issue occurred connecting to the specified wireless network. " - "You may need to move closer to your wireless gateway, or reset your hardware and try again.\n\n" - "Technical details: %1").arg(msg)); + error = tr("There was an issue connecting to your wireless network. " + "You may need to move closer to your wireless gateway, or reset your hardware and try again.\n\n" + "Technical details: %1").arg(msg); } else if(msg.startsWith("CTRL-EVENT-AUTH-REJECT")) { - dialog->hide(); - QMessageBox::critical(this, tr("Could Not Connect"), - tr("An issue occurred connecting to the specified wireless network. " - "Ensure your passphrase is correct and try again.\n\n" - "Technical details: %1").arg(msg)); + error = tr("There was an issue connecting to your wireless network. " + "Ensure your passphrase is correct and try again.\n\n" + "Technical details: %1").arg(msg); } else { /* unknown message. */ return; } } + connNotify->setEnabled(false); connNotify->deleteLater(); connNotify = nullptr; + + if(!associated) { + dialog->hide(); + QMessageBox::critical(this, tr("Could Not Connect"), error); + } + return; } -- cgit v1.2.3-60-g2f50