As I am not so sure in correctness of my solution so I'll post one question here.
So the problem is that scanElements function which applies any given function on every element really scans elements but some elements can be scanned more than once. The "select all similar" feature is implemented by selecting all relevant elements via scanElements. That would be OK but Score::selectAdd function that is used to add elements to the selection can somehow decide to deselect an element if it was already selected! The problem with ties is apparently only in being scanned even number of times.
So here is my question. That deselection feature has one obvious application for deselecting elements on being clicked one more time. However this is already successfully handled in ScoreView, and this really seems to be an appropriate place for that. Are there any other cases when we need to deselect selected element in such a way or this deselection code can be removed from Score::selectAdd? If it can be removed that would solve this issue.
So I checked those placed in the code that call Score::select with SelectType::ADD argument and neither of them seems to rely on elements deselection in selectAdd which is logical. So I propose not to deselect elements there since it is not what we really expect from this function. See https://github.com/musescore/MuseScore/pull/4063
Comments
This nightly works: 12143ca
Not the next one: 217b5fc
Still actual and important.
As I am not so sure in correctness of my solution so I'll post one question here.
So the problem is that
scanElements
function which applies any given function on every element really scans elements but some elements can be scanned more than once. The "select all similar" feature is implemented by selecting all relevant elements viascanElements
. That would be OK butScore::selectAdd
function that is used to add elements to the selection can somehow decide to deselect an element if it was already selected! The problem with ties is apparently only in being scanned even number of times.So here is my question. That deselection feature has one obvious application for deselecting elements on being clicked one more time. However this is already successfully handled in ScoreView, and this really seems to be an appropriate place for that. Are there any other cases when we need to deselect selected element in such a way or this deselection code can be removed from
Score::selectAdd
? If it can be removed that would solve this issue.In reply to As I am not so sure in… by dmitrio95
I may assume that deselecting is done because the author didn't introduce a set of unique elements.
So I checked those placed in the code that call
Score::select
withSelectType::ADD
argument and neither of them seems to rely on elements deselection inselectAdd
which is logical. So I propose not to deselect elements there since it is not what we really expect from this function. See https://github.com/musescore/MuseScore/pull/4063Fixed in branch master, commit 11dfe3f42f
fix #266205: do not deselect elements in Score::selectAdd
Fixed in branch master, commit 82b4dd18a3
Merge pull request #4063 from dmitrio95/266205-fix-select-similar
fix #266205: do not deselect elements in Score::selectAdd
Automatically closed -- issue fixed for 2 weeks with no activity.