Changing Time Signature causes existing measure rest to move

• Mar 23, 2017 - 16:11
Reported version
Graphical (UI)
S3 - Major

In this thread we discussed time signatures causing rests to move around in the score. I have finally discovered how to reproduce this from scratch. I've attached my score and this is what I did:

1. new score - choose instruments
2. add 3 instruments (click OK) - it may work with 2 instruments I didn't test it.
3. I used 6/8 time signature but it works on others as well
4. Reopen instruments and hide 1 instrument
5. Insert a different time signature into a measure after 1

result is the rest in the measure with the time signature jumps to later in the score. If you click the last note/rest in the measure before the time change and press right arrow the screen will jump to the spot the rest moved to. adding a note (such as pressing 4 B at this time will cause the measure to display properly and the screen will return to that measure.

Attachment Size
Moving rests.mscz 9.02 KB


It appears the issue is here:

We are trying to center the rest between the time signature (in this case) and the end barline. We loop through the staves figuring out where the time signature ends (since it might have different positions or widths on different staves). Unfortunately, the time signature on the invisible staff has not been laid out yet, so its position is garbage. Well, it seems to be a meaningful number, it just isn't *right*.

Probably the fix is to skip invisible staves when doing this calculation. But I also wonder if maybe we shouldn't force a layout upon adding the time signature. I know there are some similar issues with key signatures on invisible staves affecting layout in bad ways - see, a proposed partial fix for [#50216].

Further analysis would be prudent here. I do suspect skipping invisible staves in the loop mentioned above will be the best solution - and it does work to do "if (!visible(staffIdx)) continue" at the top of the loop, but we'd want to think through and be sure there are no bad side effects.

Workaround, BTW, is to show the staff then hide it again.

Status (old) active patch (code needs review)

Well, for better or worse, here is a PR implementing the simple strategy of skipping invisible staves:

BTW, there is no actual corruption, it's a layout glitch only. And in addition to fixing itself if you temporarily display the invisible staff, it also fixes itself if you save then reload the score. So not quite as bad as it might first appear, but bad enough.