From 512b6941140417377751b719de20e4a46ce03a9e Mon Sep 17 00:00:00 2001 From: Manuel Date: Sat, 13 Jan 2018 16:27:19 +0100 Subject: [PATCH] Fix crash when Tab is pressed at the last cell of a view's grid (#1289) The crash is avoided if the table model is not editable, since insertRows checks that. A table model for a DB view should be not editable, so this fix avoids the crash and possibly other possible misbehaviours. --- src/sqlitetablemodel.cpp | 2 +- src/sqlitetablemodel.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp index e606e158..f28854b6 100644 --- a/src/sqlitetablemodel.cpp +++ b/src/sqlitetablemodel.cpp @@ -938,7 +938,7 @@ void SqliteTableModel::setPseudoPk(const QString& pseudoPk) bool SqliteTableModel::isEditable() const { - return !m_sTable.isEmpty(); + return !m_sTable.isEmpty() && m_db.getObjectByName(m_sTable)->type() == sqlb::Object::Types::Table; } void SqliteTableModel::waitForFetchingFinished() diff --git a/src/sqlitetablemodel.h b/src/sqlitetablemodel.h index d61ba0fd..4170013c 100644 --- a/src/sqlitetablemodel.h +++ b/src/sqlitetablemodel.h @@ -64,7 +64,7 @@ public: // This returns true if the model is set up for editing. The model is able to operate in more or less two different modes, table browsing // and query browsing. We only support editing data for the table browsing mode and not for the query mode. This function returns true if - // the model is currently editable, i.e. it's running in table mode. + // the model is currently editable, i.e. it's running in table mode and it isn't a view. bool isEditable() const; // Helper function for removing all comments from a SQL query