From f4fad4afcf19577796be8890e1c84770de70cf63 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Mon, 26 Jun 2017 12:39:50 +0200 Subject: [PATCH] Fix possible crash when loading project files This fixes a crash when loading project files that haven't set the current tab to the Browse Data tab. See issue #1019. --- src/MainWindow.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 286a0593..db2fc93f 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1964,11 +1964,14 @@ bool MainWindow::loadProject(QString filename, bool readOnly) QByteArray temp = QByteArray::fromBase64(attrData.toUtf8()); QDataStream stream(temp); stream >> browseTableSettings; - populateTable(); // Refresh view - ui->dataTable->sortByColumn(browseTableSettings[ui->comboBrowseTable->currentText()].sortOrderIndex, - browseTableSettings[ui->comboBrowseTable->currentText()].sortOrderMode); - showRowidColumn(browseTableSettings[ui->comboBrowseTable->currentText()].showRowid); - unlockViewEditing(!browseTableSettings[ui->comboBrowseTable->currentText()].unlockViewPk.isEmpty(), browseTableSettings[ui->comboBrowseTable->currentText()].unlockViewPk); + if(ui->mainTab->currentIndex() == BrowseTab) + { + populateTable(); // Refresh view + ui->dataTable->sortByColumn(browseTableSettings[ui->comboBrowseTable->currentText()].sortOrderIndex, + browseTableSettings[ui->comboBrowseTable->currentText()].sortOrderMode); + showRowidColumn(browseTableSettings[ui->comboBrowseTable->currentText()].showRowid); + unlockViewEditing(!browseTableSettings[ui->comboBrowseTable->currentText()].unlockViewPk.isEmpty(), browseTableSettings[ui->comboBrowseTable->currentText()].unlockViewPk); + } xml.skipCurrentElement(); } }