diff --git a/src/ui/util/model/stringlistmodel.cpp b/src/ui/util/model/stringlistmodel.cpp index f909c382..9bcfceea 100644 --- a/src/ui/util/model/stringlistmodel.cpp +++ b/src/ui/util/model/stringlistmodel.cpp @@ -103,8 +103,12 @@ void StringListModel::reset() void StringListModel::refresh() { + const int rowCount = this->rowCount(); + if (rowCount <= 0) + return; + const auto firstCell = index(0, 0); - const auto lastCell = index(rowCount() - 1, 0); + const auto lastCell = index(rowCount - 1, 0); emit dataChanged(firstCell, lastCell); } diff --git a/src/ui/util/model/tableitemmodel.cpp b/src/ui/util/model/tableitemmodel.cpp index 81da6fa5..eeffa5e3 100644 --- a/src/ui/util/model/tableitemmodel.cpp +++ b/src/ui/util/model/tableitemmodel.cpp @@ -65,8 +65,12 @@ void TableItemModel::refresh() { invalidateRowCache(); + const int rowCount = this->rowCount(); + if (rowCount <= 0) + return; + const auto firstCell = index(0, 0); - const auto lastCell = index(rowCount() - 1, columnCount(firstCell) - 1); + const auto lastCell = index(rowCount - 1, columnCount(firstCell) - 1); emit dataChanged(firstCell, lastCell); }