Fix crashes from accessing invalid pointers.
This commit is contained in:
parent
ead3ce8a8a
commit
5f2857f12a
2 changed files with 10 additions and 5 deletions
|
|
@ -41,7 +41,10 @@ QueryTool::QueryTool(IDatabaseWindow *context, QWidget *parent)
|
||||||
ui->queryEdit->setFont(UserConfiguration::instance()->codeFont());
|
ui->queryEdit->setFont(UserConfiguration::instance()->codeFont());
|
||||||
|
|
||||||
highlighter = new SqlSyntaxHighlighter(ui->queryEdit->document());
|
highlighter = new SqlSyntaxHighlighter(ui->queryEdit->document());
|
||||||
highlighter->setTypes(*m_catalog->types());
|
auto types = m_catalog->types();
|
||||||
|
if (types) {
|
||||||
|
highlighter->setTypes(*types);
|
||||||
|
}
|
||||||
|
|
||||||
connect(ui->queryEdit, &QPlainTextEdit::textChanged, this, &QueryTool::queryTextChanged);
|
connect(ui->queryEdit, &QPlainTextEdit::textChanged, this, &QueryTool::queryTextChanged);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,12 +47,14 @@ void TypeSelectionItemModel::setTypeList(std::shared_ptr<const PgTypeContainer>
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_types.clear();
|
m_types.clear();
|
||||||
|
if (types) {
|
||||||
for (const auto &e : *types) {
|
for (const auto &e : *types) {
|
||||||
if (e.category != TypCategory::Array && e.type != "c") {
|
if (e.category != TypCategory::Array && e.type != "c") {
|
||||||
m_types.push_back(e.objectName());
|
m_types.push_back(e.objectName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::sort(m_types.begin(), m_types.end());
|
std::sort(m_types.begin(), m_types.end());
|
||||||
|
}
|
||||||
//emit dataChanged(this->createIndex(0, 0), this->createIndex(types->count(), 0), QVector<int>() << Qt::DisplayRole);
|
//emit dataChanged(this->createIndex(0, 0), this->createIndex(types->count(), 0), QVector<int>() << Qt::DisplayRole);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue