Corruption on delete of 5/8 time signature changing to 3/4

• Aug 24, 2016 - 05:05
Reported version
S2 - Critical

I have noticed some irregularities with Musescore when a piece that is in 5/8 switches to 3/4 time, but then when I decide to delete the 3/4 time signature, the file becomes corrupt and there are irregular measures.

In Musescore 2, this is a critical issue as the resulting file will crash Musescore when attempting to edit the corrupt file, but in Musescore 3 (the nightly build f6ce46e was tested) this merely produced a measure with missing beats, and it was easily edited without a crash. But Musescore 3 should not produce measures lacking the proper number of beats.

Attached are files illustrating the situation in Musescore 2 and 3. The corruption occurs after measure 9.


In order to investigate further, we would need to know precise steps to reproduce the corruption - the already-corrupted file isn't so useful. For information on how you can fix the corruption, see

EDIT: ok, I see how to reproduce this:

1) load original file
2) click the 3/4 in top staff measure 4
3) press Delete

Not sure what's special about this score that creates the corruptionl; in general deleting time signatures works fine.

Title Time signature switch between 5/8 and 3/4 causes problems Corruption on delete of 5/8 time signature changing to 3/4

Confirmed in score created from scratch:

1) my first score
2) create 5/8 time signature in Time SIgnatures palette if necessary
3) add to beginning of score
4) add 3/4 to second measure
5) add dotted half note to second measure
6) delete the 3/4

Result: apparent corruption in bar 2, 5/8 bar shows a single stemless quarter note (shown as duration "invalid" in the status line)

The problem comes from function TrackList::write in libmscore\range.cpp
Here (line 364) the duration is computed as 5/8 and then this value is assigned to the chord duration (at line 384-385).
It is similar to what was happening in #36186: Crash when pasting over second voice when the left-over portion of the note spans over an invalid duration and #35851: Crash when pasting measures in another measure with different actual duration.
The solution could be the use of function toDurationList or (maybe better) toRhythmicDurationList of libmscore/durationtype.cpp and create the new chordrests when necessary (i.e. 2/4 tied to 1/8 or 1/4 dotted tied to 1/4, following the rhytmic division of the time signature).
I didn't check in detail, but if toRhythmicDurationList takes into account the rhytmic division related to the time signature, it probably should substitute all (or most of) the "toDurationList" still present in the code.