From 76a697c3f614c7e673c4b77b36b98f8da4d21661 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Thu, 8 Jun 2023 21:23:28 +0200 Subject: [PATCH] Fix another invalid index --- src/models/collapsestateproxymodel.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/models/collapsestateproxymodel.cpp b/src/models/collapsestateproxymodel.cpp index f722986a0..bbd5657c3 100644 --- a/src/models/collapsestateproxymodel.cpp +++ b/src/models/collapsestateproxymodel.cpp @@ -11,8 +11,9 @@ bool CollapseStateProxyModel::filterAcceptsRow(int source_row, const QModelIndex Q_UNUSED(source_parent); return sourceModel()->data(sourceModel()->index(source_row, 0), MessageEventModel::DelegateTypeRole) != MessageEventModel::DelegateType::State // If this is not a state, show it - || sourceModel()->data(sourceModel()->index(source_row + 1, 0), MessageEventModel::DelegateTypeRole) - != MessageEventModel::DelegateType::State // If this is the first state in a block, show it. TODO hidden events? + || (source_row < sourceModel()->rowCount() - 1 + && sourceModel()->data(sourceModel()->index(source_row + 1, 0), MessageEventModel::DelegateTypeRole) + != MessageEventModel::DelegateType::State) // If this is the first state in a block, show it. TODO hidden events? || sourceModel()->data(sourceModel()->index(source_row, 0), MessageEventModel::ShowSectionRole).toBool(); // If it's a new day, show it }