Skip to content

Commit

Permalink
Fix crash when selecting the last measure in a certain score
Browse files Browse the repository at this point in the history
Resolves: musescore#17829

In this score, the last segment is not the last enabled segment. So, even though `segment` is not yet equal to `rangeEndSegment`, `nextSegment` is nullptr, because apparently there is no next _enabled_ segment.

I'm not sure if it is an expected situation that the last segment of a score is not enabled, especially because in this case it seems to be a remnant of a courtesy key signature for a next measure that is not present anymore. But apparently that can happen. Still, I wonder if that _should_ be possible to happen; or are we fixing a symptom of some problem rather than the problem itself? For example, should we instead do something in the reading code to remove that weird courtesy key signature?
  • Loading branch information
cbjeukendrup committed Jun 7, 2023
1 parent 43fb654 commit 6388270
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/notation/internal/notationselectionrange.cpp
Expand Up @@ -223,8 +223,17 @@ const
mu::engraving::System* currentSegmentSystem = segment->measure()->system();

mu::engraving::Segment* nextSegment = segment->next1MMenabled();
mu::engraving::System* nextSegmentSystem = nextSegment->measure()->system();
if (!nextSegment) {
RangeSection section;
section.system = currentSegmentSystem;
section.startSegment = startSegment;
section.endSegment = segment;

sections.push_back(section);
break;
}

mu::engraving::System* nextSegmentSystem = nextSegment->measure()->system();
if (!nextSegmentSystem) {
const Measure* mmr = nextSegment->measure()->mmRest1();
if (mmr) {
Expand Down

0 comments on commit 6388270

Please sign in to comment.