Skip to content

Commit 31ded8a

Browse files
committed
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.
1 parent 112e008 commit 31ded8a

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/TableBrowser.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,10 @@ void TableBrowser::applySettings(const BrowseDataTableSettings& storedData, bool
785785

786786
// Column widths
787787
for(auto widthIt=storedData.columnWidths.constBegin();widthIt!=storedData.columnWidths.constEnd();++widthIt)
788-
ui->dataTable->setColumnWidth(widthIt.key(), widthIt.value());
788+
{
789+
if(widthIt.key() < ui->dataTable->model()->columnCount())
790+
ui->dataTable->setColumnWidth(widthIt.key(), widthIt.value());
791+
}
789792
m_columnsResized = true;
790793

791794
// Filters
@@ -963,6 +966,9 @@ void TableBrowser::hideColumns(int column, bool hide)
963966
// (Un)hide requested column(s)
964967
for(int col : columns)
965968
{
969+
if(col >= ui->dataTable->model()->columnCount())
970+
continue;
971+
966972
ui->dataTable->setColumnHidden(col, hide);
967973
if(!hide)
968974
ui->dataTable->setColumnWidth(col, ui->dataTable->horizontalHeader()->defaultSectionSize());

src/sql/Query.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ std::string Query::buildWherePart() const
2525
{
2626
for(auto i=m_where.cbegin();i!=m_where.cend();++i)
2727
{
28+
if(i->first >= m_column_names.size())
29+
continue;
30+
2831
const auto it = findSelectedColumnByName(m_column_names.at(i->first));
2932
std::string column = sqlb::escapeIdentifier(m_column_names.at(i->first));
3033
if(it != m_selected_columns.cend() && it->selector != column)

0 commit comments

Comments
 (0)