Annotations deleted on delete even when excluded from selection via filter

• Nov 23, 2014 - 00:17
Type
Functional
Severity
S4 - Minor
Status
closed
Project

Ubuntu 14.04, GIT commit: c76f6f3

1) empty score
2) enter notes into two measures
3) add chord symbols to first note of each measure
4) selection filter
5) uncheck chord symbols
6) select all
7) edit / cut (delete key itself doesn't work unless you click in score first, and that clears selection)

Result: notes and chords are both deleted

I remember some back and forth during development over whether chords should be deleted along with notes by default. They weren't in 1.3, and that was considered (by me anyhow) a feature of sorts. When we decided it was better for a range to include all elements within it - including chord symbols - I assumed the selection filter would still provide a way of removing notes without chord symbols. I don't remember there being a reason why this wouldn't be the case.

BTW, if you enter two chord symbols in an empty measure (Ctrl+K C7 Space Space D7 Esc) then select all, the second chord symbol does not show as being selected. I guess that's because it an annotation on an otherwise empty segment. That's a bug too.


Comments

Title Chord symbols deleted on delete even when excluded from selection via filter Annotations deleted on delete even when excluded from selection via filter

Same for dynamics & staff text. Starting to wonder if this isn't some design choice that makes sense for some I can't remember.

The problem is here:

https://github.com/musescore/MuseScore/blob/d70c298c6797156b6591f498ce3…

If we want delete to not affect annotations excluded from the selection via filter, we need to skip them in this loop.

I tried two different ways, both seem to work. Either:

if (!annotation->selected())
      continue;

or

if (!selectionFilter().canSelect(annotation))
      continue;

That is, we either check the selected status of individual elements, or check the filter. Not sure if one would be preferable for some reason. Or if there is some reason this isn't being done already.

The issue with annotations on otherwise empty segments not appearing as selected when selecting a region containing them is caused in this loop within Selection::updateSelectedElements():

https://github.com/musescore/MuseScore/blob/d70c298c6797156b6591f498ce3…

The first thing we do in this loop (after skipping the end bar line) is to continue if the segment contains no element for the track. So for otherwise empty segments, we never reach the code a few lines later where annotations are marked.

I can fix this by moving the code to mark annotations to the top of the loop. But it occurs to me this code is a bit odd. We end up re-checking then re-marking the same annotation over and over - once for each track in the outer loop. I guess it's somewhat unavoidable given the difference in how the annotations versus elements are stored, but it would be a little more efficient to only check each annotation agaisnt the current track. I realize that probably made no sense. Anyhow, if someone gives me the go ahead to implement one of the above two fixes for the deletion, I'll do this too.