From 18e2be584380150c2cbe6eb9dbc254f845018da6 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Wed, 20 Sep 2023 14:26:42 +0200 Subject: [PATCH] Run ScoreDefSetCurrentPage only once --- src/doc.cpp | 5 ----- src/setscoredeffunctor.cpp | 17 +++++++---------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/doc.cpp b/src/doc.cpp index ee5d7da258b..b36a19f5b59 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -883,12 +883,7 @@ void Doc::ScoreDefSetCurrentDoc(bool force) } // First we need to set Page::m_score and Page::m_scoreEnd - // We do it by going BACKWARD, with a depth limit of 3 (we want to hit the Score elements) ScoreDefSetCurrentPageFunctor scoreDefSetCurrentPage(this); - scoreDefSetCurrentPage.SetDirection(BACKWARD); - this->Process(scoreDefSetCurrentPage, 3); - // Do it again FORWARD to set Page::m_scoreEnd - relies on Page::m_score not being NULL - scoreDefSetCurrentPage.SetDirection(FORWARD); this->Process(scoreDefSetCurrentPage, 3); ScoreDefSetCurrentFunctor scoreDefSetCurrent(this); diff --git a/src/setscoredeffunctor.cpp b/src/setscoredeffunctor.cpp index 3059cc78ee8..144bc4d3248 100644 --- a/src/setscoredeffunctor.cpp +++ b/src/setscoredeffunctor.cpp @@ -66,16 +66,13 @@ ScoreDefSetCurrentPageFunctor::ScoreDefSetCurrentPageFunctor(Doc *doc) : DocFunc FunctorCode ScoreDefSetCurrentPageFunctor::VisitPageEnd(Page *page) { - if (!page->m_score) { - const Object *firstSystem = page->GetFirst(SYSTEM); - const Object *reference = firstSystem ? firstSystem : page; - page->m_score = m_doc->GetCorrespondingScore(reference); - } - else { - const Object *lastSystem = page->GetLast(SYSTEM); - const Object *reference = lastSystem ? lastSystem : page; - page->m_scoreEnd = m_doc->GetCorrespondingScore(reference); - } + const Object *firstSystem = page->GetFirst(SYSTEM); + const Object *reference = firstSystem ? firstSystem : page; + page->m_score = m_doc->GetCorrespondingScore(reference); + + const Object *lastSystem = page->GetLast(SYSTEM); + reference = lastSystem ? lastSystem : page; + page->m_scoreEnd = m_doc->GetCorrespondingScore(reference); return FUNCTOR_CONTINUE; }