Crash by reseting/editing lyrics with underscore before rests

• Jun 24, 2017 - 07:27
Reported version
2.1
Type
Functional
Severity
S2 - Critical
Status
closed
Project

2.1 version 871c8ce / Windows7

1) Default "Untitled" score
2) Enter four quarter notes
3) Ctrl + L -> enter a syllabe
4) Press _ (underscore) key as many times until it is stopped (ie, by a rest)
lyr1.jpg
5) Press Arrow/Up or Down
6) Ctrl + R

Result: crash

- In fact, the step #5 is not necessary to get the crash
Do simply: Step #4 -> Ctrl + R

Result: Crash
second crash.jpg


Comments

So, this issue appears on January 19, 2015

- This nightly works: 16764d4
- Not the next one: 140a510

So, my first guess is that the culprit is located two commits before, ie: https://github.com/musescore/MuseScore/pull/1635/files (with comments: https://github.com/musescore/MuseScore/pull/1635)

- Before this commit, the underscore was stopped at the previous note before a rest.
Like this (and since "always", ie beginning year 2014)
before.jpg

- The same day, later, there was other commits about lyrics (eg: https://github.com/musescore/MuseScore/pull/1637) but apparently not related, since the crash occurs previously.

Title Crash by reseting lyrics with underscore before rests Crash by reseting/editing lyrics with underscore before rests

Other aspect:

Same four first steps, ie:
1) Default "Untitled" score
2) Enter four quarter notes
3) Ctrl + L -> enter a syllabe
4) Press _ (underscore) key as many times until it is stopped (ie, by a rest)
+
5) Ctrl + E
6) Click on the text box
Result: "Runtime error..." -> Ok -> Crash
edit.jpg

Interesting bug. The problem is that MuseScore still thinks we are in Edit mode, even though really hitting the rest was supposed to have kicked us back to Normal mode. Because we are supposedly in Edit mode, we are trying to reset the currently edited object, but there is no currently edited object because we aren't *really* in Edit mode, and thus the crash.

Easy enough to avoid the crash by checking for a valid editObject, but better to understand why MuseScore thinks we are still in Edit mode.

I believe the issue is that directly calling mscore->changeState() to swtich to Normal mode does part of the job but not the whole thing. In particular, it doesn't affect the StateMachine, and thus when we use editMode(0 to query the current mode, we still show as being in Edit mode. Not sure the best way to deal with that.