Augmentation dot button is not disabled when playing score

• Jun 23, 2018 - 09:53
Reported version
2.3
Type
Functional
Severity
3
Status
closed
Project

See the attached gif:

aug_dot_disable.gif

2.2.1 affected too, but there is no time to fix it there.


Comments

These lines in MuseScore::changeState() in mscore/musescore.cpp are responsible for enabling the augmentation dot:

else if (s->key() == "pad-dot" || s->key() == "pad-dot-dot" || s->key() == "delete")
a->setEnabled(!(val & (STATE_ALLTEXTUAL_EDIT | STATE_EDIT)));

They were added in order to fix #23473: Notes and rests shorter than 128th do not display or copy properly and #227826: Regression: In any Text-area, you are prevented from using the (Del) key.. Their purpose is to disable the augmentation dot and delete commands in order to allow the period and the delete key to be used for text editing, and to enable the commands when not editing text. The reason the double dot button remains disabled is because "pad-dot-dot" is a misspelling of "pad-dotdot". It was probably included for completeness, but this was before "pad-dot3" and "pad-dot4" were added. The "pad-dotdot" command does not even have a default shortcut key.

These lines no longer seem to be necessary, at least on macOS, and when the delete key is the backspace key. But in case they are still necessary for other environments, they can be changed to this:

else if (s->key() == "pad-dot" || s->key() == "pad-dotdot" || s->key() == "delete")
a->setEnabled(!(val & (STATE_ALLTEXTUAL_EDIT | STATE_EDIT | STATE_PLAY)));

The double dot was not affected because of the typo. Correcting the typo would cause it to be affected, if not for the change in the second line. Checking for STATE_PLAY is what really fixes the issue.

After looking at this some more, I am convinced that these two lines can be removed. Without them, the final else clause will be executed, which will do the right thing in all cases that were not handled earlier. "pad-dot", "pad-dotdot", and "delete" are only valid in STATE_NORMAL and STATE_NOTE_ENTRY, as defined in mscore/shortcut.cpp. Thus, for these shortcuts, s->state() evaluates to (STATE_NORMAL | STATE_NOTE_ENTRY), and so (s->state() & val) will be considered true when changing to STATE_NORMAL or STATE_ENTRY_MODE, and false otherwise. Therefore, these commands will be enabled when they are supposed to be enabled, and disabled when they are supposed to be disabled, without special handling.

Severity
Status (old) patch (code needs review) fixed
Status fixed

Fixed in branch master, commit 41cb77a5f8

fix #273606: Augmentation dot issue

Remove excessive statement in MuseScore::changeState(ScoreState val)