From a2b9f94015fea826e6e9bc0159de616d5b88e448 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Thu, 26 Sep 2024 00:03:26 +0800 Subject: [PATCH] fix: last line of lyrics is incorrect --- lyricsmanager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lyricsmanager.cpp b/lyricsmanager.cpp index 89defcd..81054a6 100644 --- a/lyricsmanager.cpp +++ b/lyricsmanager.cpp @@ -123,12 +123,12 @@ void LyricsManager::updateCurrentTimeMs(int curTimeMs, int totalTimeMs) if (!hasLyrics()) return; // TODO: we don't need to find from the top everytime the time is updated - auto iter = std::find_if(m_timestampList.begin(), m_timestampList.end() + 1, [&curTimeMs, this](int timestamp) -> bool { + auto iter = std::find_if(m_timestampList.begin(), m_timestampList.end(), [&curTimeMs, this](int timestamp) -> bool { return (timestamp + m_timeOffset) > curTimeMs; }); - m_nextLyricsTime = (iter == m_timestampList.end() + 1) ? totalTimeMs : *iter; - if (iter != m_timestampList.begin() && iter != (m_timestampList.end() + 1)) { + m_nextLyricsTime = iter == m_timestampList.end() ? totalTimeMs : *iter; + if (iter != m_timestampList.begin()) { iter--; } m_currentLyricsTime = *iter;