Fix possible crash when loading project files

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 #2232.
This commit is contained in:
Martin Kleusberg
2020-06-06 16:45:12 +02:00
parent ba1c2a10ff
commit fa04d72f20
+2 -1
View File
@@ -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());