From 1e02126706dc99174d34dc547b9a80153566fe56 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Wed, 13 May 2026 14:09:58 +0200 Subject: [PATCH] Review comments --- src/activities/browser/OpdsBookBrowserActivity.cpp | 8 ++++---- src/util/ButtonNavigator.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/activities/browser/OpdsBookBrowserActivity.cpp b/src/activities/browser/OpdsBookBrowserActivity.cpp index 988acbbb..279f64da 100644 --- a/src/activities/browser/OpdsBookBrowserActivity.cpp +++ b/src/activities/browser/OpdsBookBrowserActivity.cpp @@ -209,10 +209,10 @@ void OpdsBookBrowserActivity::loop() { return; } - buttonNavigator.onNextList(formatSelectorIndex, static_cast(entry.acquisitionLinks.size()), - [this] { requestUpdate(); }); - buttonNavigator.onPreviousList(formatSelectorIndex, static_cast(entry.acquisitionLinks.size()), - [this] { requestUpdate(); }); + buttonNavigator.onNextList({MappedInputManager::Button::Down}, formatSelectorIndex, + static_cast(entry.acquisitionLinks.size()), [this] { requestUpdate(); }); + buttonNavigator.onPreviousList({MappedInputManager::Button::Up}, formatSelectorIndex, + static_cast(entry.acquisitionLinks.size()), [this] { requestUpdate(); }); return; } diff --git a/src/util/ButtonNavigator.cpp b/src/util/ButtonNavigator.cpp index cf94bd68..1a901551 100644 --- a/src/util/ButtonNavigator.cpp +++ b/src/util/ButtonNavigator.cpp @@ -287,7 +287,8 @@ void ButtonNavigator::onListNav(const Buttons& buttons, const bool forward, int& if (isDouble) { // Restore to position before the first press so the total movement is exactly listJumpCount. - selectedIndex = indexBeforePress; + // Guard against a stale indexBeforePress if totalItems shrank since the single press stored it. + selectedIndex = (indexBeforePress >= 0 && indexBeforePress < totalItems) ? indexBeforePress : selectedIndex; for (int i = 0; i < listJumpCount; ++i) { const int next = forward ? (selectablePredicate ? nextIndex(selectedIndex) : nextIndex(selectedIndex, totalItems))