From 9669df2211014a18043acf11d2415a74115f2c5e Mon Sep 17 00:00:00 2001 From: rparkins999 Date: Tue, 17 Dec 2024 12:23:14 +0000 Subject: [PATCH] Stop DataViewer::setTableModel from crashing when new model is same as old one --- Sqliteman/sqliteman/dataviewer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sqliteman/sqliteman/dataviewer.cpp b/Sqliteman/sqliteman/dataviewer.cpp index 784757c..64af7c3 100644 --- a/Sqliteman/sqliteman/dataviewer.cpp +++ b/Sqliteman/sqliteman/dataviewer.cpp @@ -1170,8 +1170,9 @@ bool DataViewer::checkForPending() bool DataViewer::setTableModel(QAbstractItemModel * model, bool showButtons) { - if (!checkForPending()) { return false; } QAbstractItemModel * old = ui.tableView->model(); + if (old == model) { return true; } // Nothing to do, avoid SIGSEGV + if (!checkForPending()) { return false; } QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); showingChanges = false; ui.tableView->setModel(model); // references old model