Fix crash when opening MusicXML file with multiple fermatas on grace notes #26680
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves: #26593
See ChordRest::add/removeFermata and their usages: when reading a MusicXML file where there is a fermata on a grace note, the fermata is temporarily added to the grace chord, because there is no segment yet, and then later it is moved to the segment, which becomes the definitive parent of the fermata. If a MusicXML file contains multiple fermatas on one grace note, then those fermatas except the first would not be moved from the grace chord to the segment. This means that there are fermatas with no segment encountered during layout when going through that grace chord's
el()
, which causes a crash. The solution for now is to ensure that all fermatas are moved. A more definitive solution in the future might be to refactor out theadd/removeFermata
methods, because as the comment at their declaration already says, they really look like a hack.Inspired by the investigation at #26602.