summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-12-19 03:42:43 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-12-19 03:42:43 +0100
commitb314f41f6b5819144ff66cc406e669659b265364 (patch)
tree76f5c8b52eaedd73acff6d3c8ac79e3a9ec71365
parentAdd some documentation for how the background filtering works (diff)
downloadnheko-b314f41f6b5819144ff66cc406e669659b265364.tar.xz
Fix searching past the end
-rw-r--r--src/timeline/TimelineFilter.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/timeline/TimelineFilter.cpp b/src/timeline/TimelineFilter.cpp
index 36228c7c..80a4425d 100644
--- a/src/timeline/TimelineFilter.cpp
+++ b/src/timeline/TimelineFilter.cpp
@@ -61,8 +61,13 @@ TimelineFilter::event(QEvent *ev)
         incrementalSearchIndex += 30;
 
         if (auto s = source(); s) {
+            auto count = s->rowCount();
+            if (incrementalSearchIndex >= count) {
+                incrementalSearchIndex = std::numeric_limits<int>::max();
+            }
+            nhlog::ui()->debug("Filter progress {}/{}", incrementalSearchIndex, count);
             s->dataChanged(s->index(orgIndex),
-                           s->index(std::min(incrementalSearchIndex, s->rowCount() - 1)),
+                           s->index(std::min(incrementalSearchIndex, count - 1)),
                            {FilterRole});
             continueFiltering();
         }