Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/engraving/dom/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1668,13 +1668,22 @@ bool segmentsAreAdjacentInRepeatStructure(const Segment* firstSeg, const Segment
if (!firstSeg || !secondSeg) {
return false;
}
const MasterScore* master = firstSeg->masterScore();

Measure* firstMeasure = firstSeg->measure();
Measure* secondMeasure = secondSeg->measure();

if (firstMeasure == secondMeasure) {
return true;
}

const MeasureBase* firstMasterMeasureBase = master->measure(firstMeasure->index());
const Measure* firstMasterMeasure = firstMasterMeasureBase
&& firstMasterMeasureBase->isMeasure() ? toMeasure(firstMasterMeasureBase) : nullptr;
const MeasureBase* secondMasterMeasureBase = master->measure(secondMeasure->index());
const Measure* secondMasterMeasure = secondMasterMeasureBase
&& secondMasterMeasureBase->isMeasure() ? toMeasure(secondMasterMeasureBase) : nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be more immediate by doing e.g. master->tick2measure(firstMeasure->tick())? It should also be much faster after your work on tick indexing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise looks good, feel free to merge after this small change 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, definitely! I'd actually prefer to be overly cautious and make these changes in 4.6 as tick indexing won't be in the patch. This method of accessing measures has been fine for findFollowing/PreviousRepeatMeasures and I'd hate to break something now


Score* score = firstSeg->score();

const RepeatList& repeatList = score->repeatList(true, false);
Expand All @@ -1686,12 +1695,12 @@ bool segmentsAreAdjacentInRepeatStructure(const Segment* firstSeg, const Segment
const auto nextSegIt = std::next(it);

// Check if measures are in the same repeat segment
if (rs->containsMeasure(firstMeasure) && rs->containsMeasure(secondMeasure)) {
if (rs->containsMeasure(firstMasterMeasure) && rs->containsMeasure(secondMasterMeasure)) {
return true;
}

// Continue to build list of measures at the start of following repeat segments
if (!rs->endsWithMeasure(firstMeasure) || nextSegIt == repeatList.end()) {
if (!rs->endsWithMeasure(firstMasterMeasure) || nextSegIt == repeatList.end()) {
continue;
}

Expand All @@ -1707,7 +1716,7 @@ bool segmentsAreAdjacentInRepeatStructure(const Segment* firstSeg, const Segment

// Check if second segment is in a following measure in the repeat structure
for (const Measure* m : measures) {
if (m == secondSeg->measure()) {
if (m == secondMasterMeasure) {
return true;
}
}
Expand All @@ -1720,13 +1729,22 @@ bool segmentsAreInDifferentRepeatSegments(const Segment* firstSeg, const Segment
if (!firstSeg || !secondSeg) {
return false;
}
const MasterScore* master = firstSeg->masterScore();

Measure* firstMeasure = firstSeg->measure();
Measure* secondMeasure = secondSeg->measure();

if (firstMeasure == secondMeasure) {
return false;
}

const MeasureBase* firstMasterMeasureBase = master->measure(firstMeasure->index());
const Measure* firstMasterMeasure = firstMasterMeasureBase
&& firstMasterMeasureBase->isMeasure() ? toMeasure(firstMasterMeasureBase) : nullptr;
const MeasureBase* secondMasterMeasureBase = master->measure(secondMeasure->index());
const Measure* secondMasterMeasure = secondMasterMeasureBase
&& secondMasterMeasureBase->isMeasure() ? toMeasure(secondMasterMeasureBase) : nullptr;

Score* score = firstSeg->score();

const RepeatList& repeatList = score->repeatList(true, false);
Expand All @@ -1736,7 +1754,7 @@ bool segmentsAreInDifferentRepeatSegments(const Segment* firstSeg, const Segment
for (auto it = repeatList.begin(); it != repeatList.end(); it++) {
const RepeatSegment* rs = *it;

if (!rs->containsMeasure(firstMeasure) || !rs->containsMeasure(secondMeasure)) {
if (!rs->containsMeasure(firstMasterMeasure) || !rs->containsMeasure(secondMasterMeasure)) {
return true;
}
}
Expand Down