fix #166566: Exchange voices with partial measure selected works all the way to end of score #3790
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.
See https://musescore.org/en/node/166566.
This function seems to assume that only entire measures are selected. This is understandable, since the operation works only on entire measures. If the selection ends at the end of a measure, t2 will be set to the start tick of the next measure (or the last tick in the score if there is no next measure), and m2 will be set to the measure that starts at t2 (or the last measure in the score if t2 is the last tick in the score). The only way t2 would be greater than m2->tick() would be if m2 were the last measure in the score. If this is the case, then m2->nextMeasure() is equal to 0, so the logic has not changed. What has changed is that if the selection ends somewhere in the middle of a measure, m2 is set to the correct measure at which to stop.