Add MessageDialog and use it in place of the QMessageBox static functions

QMessageBox::information() and friends build the box on the stack, parent
it to the calling widget and run a nested event loop in exec(). If the
parent is closed while the box is open, which the Web API can do at any
time, the parent deletes the box and its children and the heap is
corrupted.

MessageDialog offers the same calls, but the box is heap allocated, given
Qt::WA_DeleteOnClose and shown rather than exec'd, so nothing runs a
nested event loop and the box owns its own lifetime. A box with the same
text as one already up is raised instead of a second being created.

The trade off is that information(), warning() and critical() return
immediately and cannot report which button was pressed. question() takes
a callback for the cases that need the answer.

Converts the call sites in the device, channel and feature GUIs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Jon Beniston
2026-09-11 17:16:49 +01:00
co-authored by Claude Opus 5
parent 60db861797
commit ddedd59568
82 changed files with 343 additions and 120 deletions
@@ -21,6 +21,7 @@
#include <libhackrf/hackrf.h>
#include "gui/messagedialog.h"
#include "gui/colormapper.h"
#include "gui/glspectrum.h"
#include "gui/basicdevicesettingsdialog.h"
@@ -464,7 +465,7 @@ void HackRFOutputGui::updateStatus()
break;
case DeviceAPI::StError:
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceAPI->errorMessage());
MessageDialog::information(this, tr("Message"), m_deviceUISet->m_deviceAPI->errorMessage());
break;
default:
break;