From 65994985566b49ef02befc51137640431bcf11e3 Mon Sep 17 00:00:00 2001 From: eelke Date: Tue, 19 Dec 2017 19:06:36 +0100 Subject: [PATCH] Better handling of not being able to connect to the database. --- pglab/MainWindow.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pglab/MainWindow.cpp b/pglab/MainWindow.cpp index 0911c8e..00cae59 100644 --- a/pglab/MainWindow.cpp +++ b/pglab/MainWindow.cpp @@ -57,9 +57,8 @@ void MainWindow::setConfig(const ConnectionConfig &config) m_config = config; try { auto res = OpenDatabase::createOpenDatabase(config); - if (res.valid()) { - m_database = res.get(); - } + //if (res.valid()) { + m_database = res.get(); QString title = "pglab - "; title += m_config.name().c_str(); setWindowTitle(title); @@ -71,9 +70,14 @@ void MainWindow::setConfig(const ConnectionConfig &config) newSqlPage(); } catch (std::runtime_error &ex) { - QMessageBox msgBox; - msgBox.setText(QString::fromUtf8(ex.what())); - msgBox.exec(); +// QMessageBox msgBox; +// msgBox.setText(QString::fromUtf8(ex.what())); +// msgBox.exec(); + + QMessageBox::critical(this, "Error reading database", + QString::fromUtf8(ex.what())); + + close(); } }