From 3535bdbf62636ce135c8ca5b2a205308bbc7773d Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Sun, 10 Nov 2019 13:41:15 +0100 Subject: [PATCH] Fix crash when searching in an empty table --- src/sqlitetablemodel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp index d096f686..d0980e4d 100644 --- a/src/sqlitetablemodel.cpp +++ b/src/sqlitetablemodel.cpp @@ -1080,6 +1080,10 @@ QModelIndex SqliteTableModel::nextMatch(const QModelIndex& start, const std::vec // Wait until the row count is there waitUntilIdle(); + // Stop right away if there is no data in the table + if(rowCount() == 0) + return QModelIndex(); + // Make sure the start position starts in a column from the list of columns to search in QModelIndex pos = start; if(std::find(column_list.begin(), column_list.end(), pos.column()) == column_list.end())