Fix: openening not accessible database crashes program.
OpenDatabase::createOpenDatabase now uses QException derived exception to report failure. This makes it possible to catch the exception in a background thread and rethrow it when the Future is read. Which makes it possible for the database window to properly report the problem.
This commit is contained in:
parent
3820fb2600
commit
ecae0464f9
5 changed files with 36 additions and 24 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include "DatabasesTableModel.h"
|
||||
#include "RolesTableModel.h"
|
||||
#include "catalog/PgDatabaseCatalog.h"
|
||||
#include <QDebug>
|
||||
|
||||
ServerWindow::ServerWindow(MasterController *master, QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
|
|
@ -27,17 +28,18 @@ ServerWindow::~ServerWindow()
|
|||
void ServerWindow::setConfig(const ConnectionConfig &config)
|
||||
{
|
||||
m_config = config;
|
||||
auto res = OpenDatabase::createOpenDatabase(config);
|
||||
if (res.valid()) {
|
||||
m_database = res.get();
|
||||
try {
|
||||
m_database = OpenDatabase::createOpenDatabase(config);
|
||||
auto cat = m_database->catalog();
|
||||
if (cat) {
|
||||
m_databasesModel->setDatabaseList(cat);
|
||||
m_rolesModel->setRoleList(cat->authIds());
|
||||
}
|
||||
}
|
||||
catch (const OpenDatabaseException &ex) {
|
||||
qWarning() << ex.text();
|
||||
}
|
||||
QString title = "pglab - ";
|
||||
title += m_config.name().c_str();
|
||||
setWindowTitle(title);
|
||||
// newSqlPage();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue