Skip to content

Commit

Permalink
Fix possible crash when loading project files
Browse files Browse the repository at this point in the history
This fixes a possible crash when loading project files which occurs with
some versions of Qt when trying to set the column widths in the Browse
Data tab.

Thanks to @hertzhaft for spotting and fixing this.

See issue sqlitebrowser#2232.
  • Loading branch information
MKleusberg committed Jun 6, 2020
1 parent ba1c2a1 commit fa04d72
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/TableBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,8 @@ void TableBrowser::applySettings(const BrowseDataTableSettings& storedData, bool
hideColumns(hiddenIt.key(), hiddenIt.value());

// Column widths
for(auto widthIt=storedData.columnWidths.constBegin();widthIt!=storedData.columnWidths.constEnd();++widthIt)
QMap<int, int> w = storedData.columnWidths; // We need to make a copy here because with some versions of Qt
for(auto widthIt=w.constBegin();widthIt!=w.constEnd();++widthIt) // the container gets modified in a way which causes a crash
{
if(widthIt.key() < ui->dataTable->model()->columnCount())
ui->dataTable->setColumnWidth(widthIt.key(), widthIt.value());
Expand Down

0 comments on commit fa04d72

Please sign in to comment.