mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-21 03:21:43 -06:00
Fix possible crashes when loading outdated project file
Fix a couple of possible crashed when loading a project file which does not match the database schema anymore. See issue #2232.
This commit is contained in:
@@ -785,7 +785,10 @@ void TableBrowser::applySettings(const BrowseDataTableSettings& storedData, bool
|
||||
|
||||
// Column widths
|
||||
for(auto widthIt=storedData.columnWidths.constBegin();widthIt!=storedData.columnWidths.constEnd();++widthIt)
|
||||
ui->dataTable->setColumnWidth(widthIt.key(), widthIt.value());
|
||||
{
|
||||
if(widthIt.key() < ui->dataTable->model()->columnCount())
|
||||
ui->dataTable->setColumnWidth(widthIt.key(), widthIt.value());
|
||||
}
|
||||
m_columnsResized = true;
|
||||
|
||||
// Filters
|
||||
@@ -963,6 +966,9 @@ void TableBrowser::hideColumns(int column, bool hide)
|
||||
// (Un)hide requested column(s)
|
||||
for(int col : columns)
|
||||
{
|
||||
if(col >= ui->dataTable->model()->columnCount())
|
||||
continue;
|
||||
|
||||
ui->dataTable->setColumnHidden(col, hide);
|
||||
if(!hide)
|
||||
ui->dataTable->setColumnWidth(col, ui->dataTable->horizontalHeader()->defaultSectionSize());
|
||||
|
||||
@@ -25,6 +25,9 @@ std::string Query::buildWherePart() const
|
||||
{
|
||||
for(auto i=m_where.cbegin();i!=m_where.cend();++i)
|
||||
{
|
||||
if(i->first >= m_column_names.size())
|
||||
continue;
|
||||
|
||||
const auto it = findSelectedColumnByName(m_column_names.at(i->first));
|
||||
std::string column = sqlb::escapeIdentifier(m_column_names.at(i->first));
|
||||
if(it != m_selected_columns.cend() && it->selector != column)
|
||||
|
||||
Reference in New Issue
Block a user