fix #290187: crash on paste clef/key/time signature #5098
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.
See https://musescore.org/en/node/290187
Crash comes from my code to re-establish the selection upon pasting an element onto another of the same type. Turns out my assumption that this resulted in replacing the target with the new element is wrong elements other than notes. So, I've adjusted this code to be more specific: we do the special handling only when dropping notes. In that case, we deselect the target because we know it is being replaced, then select the new note when dropping a note onto a nother note. We don't select anything here when dropping a note onto a rest because it turns out both the original rest and the dropped note are invalid here because a new note is generated (and, luckily, selected for us) in ChordRest::drop().
Tested now with combinations or notes, rests, clefs, key & time signatures, and also pasting other elements (text, articuations, etc) onto notes.