Merge pull request #140 from jgoguen/fix-cppcheck-finding

refactor: Clean up cppcheck finding causing tests to fail
This commit is contained in:
jpirnay
2026-04-27 10:44:55 +02:00
committed by GitHub
+14 -13
View File
@@ -12,13 +12,14 @@
#include <HalStorage.h> #include <HalStorage.h>
#include <I18n.h> #include <I18n.h>
#include <algorithm>
#include "CrossPointSettings.h" #include "CrossPointSettings.h"
#include "CrossPointState.h" #include "CrossPointState.h"
#include "MappedInputManager.h" #include "MappedInputManager.h"
#include "ReaderUtils.h" #include "ReaderUtils.h"
#include "RecentBooksStore.h" #include "RecentBooksStore.h"
#include "XtcReaderChapterSelectionActivity.h" #include "XtcReaderChapterSelectionActivity.h"
#include "components/UITheme.h"
#include "fontIds.h" #include "fontIds.h"
namespace { namespace {
@@ -462,24 +463,24 @@ void XtcReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION a
case BA::BTN_NEXT_SECTION: case BA::BTN_NEXT_SECTION:
if (xtc->hasChapters()) { if (xtc->hasChapters()) {
const auto& chapters = xtc->getChapters(); const auto& chapters = xtc->getChapters();
for (const auto& ch : chapters) { const auto nextChapter = std::find_if(chapters.begin(), chapters.end(),
if (ch.startPage > currentPage) { [this](const auto& ch) { return ch.startPage > currentPage; });
currentPage = ch.startPage;
requestUpdate(); if (nextChapter != chapters.end()) {
break; currentPage = nextChapter->startPage;
} requestUpdate();
} }
} }
break; break;
case BA::BTN_PREV_SECTION: case BA::BTN_PREV_SECTION:
if (xtc->hasChapters()) { if (xtc->hasChapters()) {
const auto& chapters = xtc->getChapters(); const auto& chapters = xtc->getChapters();
for (int i = static_cast<int>(chapters.size()) - 1; i >= 0; i--) { const auto prevChapter = std::find_if(chapters.rbegin(), chapters.rend(),
if (chapters[i].startPage < currentPage) { [this](const auto& ch) { return ch.startPage < currentPage; });
currentPage = chapters[i].startPage;
requestUpdate(); if (prevChapter != chapters.rend()) {
break; currentPage = prevChapter->startPage;
} requestUpdate();
} }
} }
break; break;