From fa04d72f20fc84f1620b8f5a27495837e52e2dc3 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Sat, 6 Jun 2020 16:45:12 +0200 Subject: [PATCH] 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. --- src/TableBrowser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TableBrowser.cpp b/src/TableBrowser.cpp index e2553c22..372679a5 100644 --- a/src/TableBrowser.cpp +++ b/src/TableBrowser.cpp @@ -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 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());