refactor: Clean up cppcheck finding causing tests to fail

This commit is contained in:
Joel Goguen
2026-04-26 18:58:00 -04:00
parent c32757e4a1
commit 3814f10b1b
+14 -13
View File
@@ -12,13 +12,14 @@
#include <HalStorage.h>
#include <I18n.h>
#include <algorithm>
#include "CrossPointSettings.h"
#include "CrossPointState.h"
#include "MappedInputManager.h"
#include "ReaderUtils.h"
#include "RecentBooksStore.h"
#include "XtcReaderChapterSelectionActivity.h"
#include "components/UITheme.h"
#include "fontIds.h"
namespace {
@@ -462,24 +463,24 @@ void XtcReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION a
case BA::BTN_NEXT_SECTION:
if (xtc->hasChapters()) {
const auto& chapters = xtc->getChapters();
for (const auto& ch : chapters) {
if (ch.startPage > currentPage) {
currentPage = ch.startPage;
requestUpdate();
break;
}
const auto nextChapter = std::find_if(chapters.begin(), chapters.end(),
[this](const auto& ch) { return ch.startPage > currentPage; });
if (nextChapter != chapters.end()) {
currentPage = nextChapter->startPage;
requestUpdate();
}
}
break;
case BA::BTN_PREV_SECTION:
if (xtc->hasChapters()) {
const auto& chapters = xtc->getChapters();
for (int i = static_cast<int>(chapters.size()) - 1; i >= 0; i--) {
if (chapters[i].startPage < currentPage) {
currentPage = chapters[i].startPage;
requestUpdate();
break;
}
const auto prevChapter = std::find_if(chapters.rbegin(), chapters.rend(),
[this](const auto& ch) { return ch.startPage < currentPage; });
if (prevChapter != chapters.rend()) {
currentPage = prevChapter->startPage;
requestUpdate();
}
}
break;