summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-01-28 22:08:30 +0100
committerGravatar Jan Mulder <jlmulder@xs4all.nl>2018-01-31 14:47:26 +0100
commita25f54e3c29a936bb1bbfa66fa610c31c9b55808 (patch)
tree2091a7339c5f8c9f7169388b7c94dac985e0b078 /desktop-widgets/mainwindow.cpp
parent1704e0801258d0ae78b18be32488e083458010f1 (diff)
downloadsubsurface-a25f54e3c29a936bb1bbfa66fa610c31c9b55808.tar.gz
Use queued connection to thread-safe MainWindow error handling
Up to now, errors produced by threads were not directly shown in the MainWindow. Code running in the GUI thread had to manually show the errors. This can be simplified by using Qt's queued connection as message passing facility. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/mainwindow.cpp')
-rw-r--r--desktop-widgets/mainwindow.cpp15
1 files changed, 2 insertions, 13 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 26c67a261..7fa12c524 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -91,21 +91,9 @@ MainWindow *MainWindow::m_Instance = NULL;
extern "C" void showErrorFromC()
{
- // Show errors only if we are running in the GUI thread.
- // If we're not in the GUI thread, let errors accumulate.
- if (QThread::currentThread() != QCoreApplication::instance()->thread())
- return;
-
MainWindow *mainwindow = MainWindow::instance();
if (mainwindow)
- mainwindow->showErrors();
-}
-
-void MainWindow::showErrors()
-{
- const char *error = get_error_string();
- if (!empty_string(error))
- getNotificationWidget()->showNotification(error, KMessageWidget::Error);
+ emit mainwindow->showError(get_error_string());
}
MainWindow::MainWindow() : QMainWindow(),
@@ -219,6 +207,7 @@ MainWindow::MainWindow() : QMainWindow(),
connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan()));
connect(this, SIGNAL(startDiveSiteEdit()), this, SLOT(on_actionDiveSiteEdit_triggered()));
connect(information(), SIGNAL(diveSiteChanged(struct dive_site *)), mapWidget, SLOT(centerOnDiveSite(struct dive_site *)));
+ connect(this, &MainWindow::showError, ui.mainErrorMessage, &NotificationWidget::showError, Qt::AutoConnection);
wtu = new WindowTitleUpdate();
connect(WindowTitleUpdate::instance(), SIGNAL(updateTitle()), this, SLOT(setAutomaticTitle()));