fix #48026: bad copy of full measure rest #1780
Merged
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.
Prior to 9a705e1, we would copy a measure rest whether it made sense or not, creating corruption. That commit fixed that, but we lost the ability to copy measure rests as measure rests. And a new corruption was introduced, if the measure rest could not be converted to a single duration rest (eg, 5/4).
Since we already have just above to split up rests that don't fit in the measure, I moved the check for duration rests to a spot earlier in the function so we could take advantage of that rest-splitting code. And I only invoke it we are pasting a measure rest to a location that is not the beginning of the measure, or if the length of the rest doesn't match the length of the measure. This allows us to still copy measure rests normally (eg, a simple range of measures). I have verified this fixes the current issue as well as the previous bug, and I also tested a variety of other cases involving 5/4, etc.
The only thing potentially off is the check to see if the rest duration matches the measure duration. Time stretch could possibly mess that up, and I don't know what the right semantics are. But I think even that calculation comes out wrong, you still get something reasonable / not corrupt.