Fixed some cases where nullptr were not correctly handled.
This commit is contained in:
parent
e66326472e
commit
aa50d3097e
3 changed files with 18 additions and 10 deletions
|
|
@ -41,7 +41,7 @@ private:
|
|||
Ui::MainWindow *ui;
|
||||
|
||||
ConnectionConfig m_config;
|
||||
OpenDatabase *m_database;
|
||||
OpenDatabase *m_database = nullptr;
|
||||
|
||||
MasterController *m_masterController;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,12 @@ Expected<OpenDatabase*> OpenDatabase::createOpenDatabase(const ConnectionConfig
|
|||
OpenDatabase *odb = new OpenDatabase(cfg, nullptr);
|
||||
if (odb->Init()) {
|
||||
|
||||
return odb;
|
||||
|
||||
}
|
||||
return odb;
|
||||
//return Expected<ConnectionConfig>::fromException(std::out_of_range("Invalid row"));
|
||||
return Expected<OpenDatabase*>::fromException(
|
||||
std::runtime_error("Failed to get database information"));
|
||||
}
|
||||
|
||||
OpenDatabase::OpenDatabase(const ConnectionConfig& cfg, QObject *parent)
|
||||
|
|
@ -33,9 +35,10 @@ bool OpenDatabase::Init()
|
|||
auto vals = m_config.getValues();
|
||||
if (conn.connect(kw, vals, 0)) {
|
||||
m_catalogue->loadAll(conn);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
PgDatabaseCatalogue* OpenDatabase::catalogue()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ QueryParamListController::QueryParamListController(QTableView *tv,
|
|||
, paramTableView(tv)
|
||||
, m_openDatabase(opendb)
|
||||
{
|
||||
if (opendb) {
|
||||
m_typeDelegate.setTypeSelectionModel(opendb->typeSelectionModel());
|
||||
}
|
||||
|
||||
paramTableView->setModel(&m_paramList);
|
||||
paramTableView->setItemDelegateForColumn(1, &m_typeDelegate);
|
||||
|
|
@ -82,17 +84,20 @@ QueryTab::QueryTab(MainWindow *win, QWidget *parent) :
|
|||
font.setPointSize(10);
|
||||
ui->queryEdit->setFont(font);
|
||||
|
||||
OpenDatabase* open_database = m_win->getDatabase();
|
||||
auto cat = open_database->catalogue();
|
||||
|
||||
highlighter = new SqlSyntaxHighlighter(ui->queryEdit->document());
|
||||
OpenDatabase* open_database = m_win->getDatabase();
|
||||
if (open_database) {
|
||||
auto cat = open_database->catalogue();
|
||||
highlighter->setTypes(cat->types());
|
||||
}
|
||||
|
||||
connect(ui->queryEdit, &QPlainTextEdit::textChanged, this, &QueryTab::queryTextChanged);
|
||||
|
||||
m_queryParamListController = new QueryParamListController(ui->paramTableView, open_database, this);
|
||||
connect(ui->addButton, &QPushButton::clicked, m_queryParamListController, &QueryParamListController::on_addParam);
|
||||
connect(ui->removeButton, &QPushButton::clicked, m_queryParamListController, &QueryParamListController::on_removeParam);
|
||||
connect(ui->addButton, &QPushButton::clicked, m_queryParamListController,
|
||||
&QueryParamListController::on_addParam);
|
||||
connect(ui->removeButton, &QPushButton::clicked, m_queryParamListController,
|
||||
&QueryParamListController::on_removeParam);
|
||||
}
|
||||
|
||||
QueryTab::~QueryTab()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue