Skip to content

Commit 1ebb637

Browse files
authored
Merge pull request #27720 from miiizen/27718-tie-parts
Fix tie toggle in parts
2 parents f0c8185 + f818b39 commit 1ebb637

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/engraving/dom/utils.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,13 +1668,22 @@ bool segmentsAreAdjacentInRepeatStructure(const Segment* firstSeg, const Segment
16681668
if (!firstSeg || !secondSeg) {
16691669
return false;
16701670
}
1671+
const MasterScore* master = firstSeg->masterScore();
1672+
16711673
Measure* firstMeasure = firstSeg->measure();
16721674
Measure* secondMeasure = secondSeg->measure();
16731675

16741676
if (firstMeasure == secondMeasure) {
16751677
return true;
16761678
}
16771679

1680+
const MeasureBase* firstMasterMeasureBase = master->measure(firstMeasure->index());
1681+
const Measure* firstMasterMeasure = firstMasterMeasureBase
1682+
&& firstMasterMeasureBase->isMeasure() ? toMeasure(firstMasterMeasureBase) : nullptr;
1683+
const MeasureBase* secondMasterMeasureBase = master->measure(secondMeasure->index());
1684+
const Measure* secondMasterMeasure = secondMasterMeasureBase
1685+
&& secondMasterMeasureBase->isMeasure() ? toMeasure(secondMasterMeasureBase) : nullptr;
1686+
16781687
Score* score = firstSeg->score();
16791688

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

16881697
// Check if measures are in the same repeat segment
1689-
if (rs->containsMeasure(firstMeasure) && rs->containsMeasure(secondMeasure)) {
1698+
if (rs->containsMeasure(firstMasterMeasure) && rs->containsMeasure(secondMasterMeasure)) {
16901699
return true;
16911700
}
16921701

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

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

17081717
// Check if second segment is in a following measure in the repeat structure
17091718
for (const Measure* m : measures) {
1710-
if (m == secondSeg->measure()) {
1719+
if (m == secondMasterMeasure) {
17111720
return true;
17121721
}
17131722
}
@@ -1720,13 +1729,22 @@ bool segmentsAreInDifferentRepeatSegments(const Segment* firstSeg, const Segment
17201729
if (!firstSeg || !secondSeg) {
17211730
return false;
17221731
}
1732+
const MasterScore* master = firstSeg->masterScore();
1733+
17231734
Measure* firstMeasure = firstSeg->measure();
17241735
Measure* secondMeasure = secondSeg->measure();
17251736

17261737
if (firstMeasure == secondMeasure) {
17271738
return false;
17281739
}
17291740

1741+
const MeasureBase* firstMasterMeasureBase = master->measure(firstMeasure->index());
1742+
const Measure* firstMasterMeasure = firstMasterMeasureBase
1743+
&& firstMasterMeasureBase->isMeasure() ? toMeasure(firstMasterMeasureBase) : nullptr;
1744+
const MeasureBase* secondMasterMeasureBase = master->measure(secondMeasure->index());
1745+
const Measure* secondMasterMeasure = secondMasterMeasureBase
1746+
&& secondMasterMeasureBase->isMeasure() ? toMeasure(secondMasterMeasureBase) : nullptr;
1747+
17301748
Score* score = firstSeg->score();
17311749

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

1739-
if (!rs->containsMeasure(firstMeasure) || !rs->containsMeasure(secondMeasure)) {
1757+
if (!rs->containsMeasure(firstMasterMeasure) || !rs->containsMeasure(secondMasterMeasure)) {
17401758
return true;
17411759
}
17421760
}

0 commit comments

Comments
 (0)