Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #315627 - Musescore 3.6 crashes when opening large orchestration created in Musescore 3.4.2 #7258

Merged
merged 1 commit into from
Jan 18, 2021

Conversation

njvdberg
Copy link
Contributor

Resolves: https://musescore.org/en/node/315627

Solve a crash in case nextMeasure() returns a nullptr instead of a pointer to a measure.

  • I signed CLA
  • I made sure the code in the PR follows the coding rules
  • I made sure the code compiles on my machine
  • I made sure there are no unnecessary changes in the code
  • I made sure the title of the PR reflects the core meaning of the issue you are solving
  • I made sure the commit message(s) contain a description and answer the question "Why do those changes fix that particular issue?" or "Why are those changes really necessary as improvements?"
  • I made sure the commit message title starts with "fix #424242:" if there is a related issue
  • I created the test (mtest, vtest, script test) to verify the changes I made

…created in Musescore 3.4.2

Solve a crash in case nextMeasure() returns a nullptr instead of a pointer to a measure.
@MarcSabatella
Copy link
Contributor

Seems nextMeasure() will always return nullptr for the last measure. So, why doesn't this crash on every score? What are the conditions that lead to this?

@njvdberg
Copy link
Contributor Author

The modified check is in Measure::isCutawayClef() and this method returns true if

  • 1 An EndBarLine segment is found and this segment and
  • 2 This segment has a Clef element and
  • 3 The next measure is on the same system.

The original check was:

e && e->isClef() && (nextMeasure()->system() == system()

So, in most cases the nextMeasure() is never called, only when the element is a Clef.

As a matter of fact, the full original check was

e && e->isClef() && (nextMeasure()->system() == system() || toClef(e)->showCourtesy()

This potentially also could cause a crash on toClef(e)->showCourtesy() if the part before the || evaluates to false and e doesn't happens to be an Clef. This also solved by first check whether e is not zero and is a Clef.

@MarcSabatella
Copy link
Contributor

MarcSabatella commented Jan 16, 2021

Answering my own question - this happens only if there is a staff whose last measure contains a clef as the last element before the barline. Not an easy thing to make happen, but one way is to add a clef change somewhere then delete all measures after the change. This results in the clef still being present but not visible. I can also get one to be visible by entering a mid-measure clef between two half notes in 4/4 then changing the first to a whole note.

EDIT: posts crossed :-)

@vpereverzev vpereverzev merged commit 9f68f34 into musescore:3.x Jan 18, 2021
@njvdberg njvdberg deleted the issue-315627-crash branch March 10, 2021 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants