Skip to content

Commit

Permalink
Run ScoreDefSetCurrentPage only once
Browse files Browse the repository at this point in the history
  • Loading branch information
brdvd committed Sep 20, 2023
1 parent c7cc783 commit 18e2be5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
5 changes: 0 additions & 5 deletions src/doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 7 additions & 10 deletions src/setscoredeffunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 18e2be5

Please sign in to comment.