crash after undo of paste that creates tie forward

• Feb 4, 2015 - 02:16
Type
Functional
Severity
S2 - Critical
Status
closed
Project

Steps to reproduce:
1. Open attached project "time sig crash 02.mscz".
2. Copy the 4/4 measure (ms. 11, both staves) and paste it to ms. 1.
3. Undo (Ctrl-Z).
4. Using the palette, drag the 3/4 time signature to ms. 2.
5. Drag the 4/4 time signature to ms. 1.

Result: segmentation fault

I am using MuseScore nightly 7b10dcc on Kubuntu 14.04 64-bit.

Attachment Size
time sig crash 02.mscz 12.05 KB

Comments

The crash occurs laying out a tie. It turns out to have nothing to do with time signatures per se - that is just the trigger. The issue is with the copy/paste & undo. What is happening is the following:

The measure being copied (11) has two ties going forward. When we copy measure 11 to measure 1, the forward ties are joined up to the first matching notes we can find - the original notes in measure 11 themselves (since there are nothing but rests in between). That's not actually a problem in itself. But when we undo the paste, the ties are not cleaned up properly - the ties are removed, but the original notes in measure 11 still have their _tieBack set to what is now a garbage value. So the crash is just waiting to happen.

I can make a simple test case as follows:

1) empty score, 4/4
2) enter whole note in measure 2, tie to something in measure 3
3) select measure 2
4) copy to measure 1, thus creating a tie from measure 1 to measure 2
5) undo

At this point, you can see in the Debugger that the note in measure 2 still has _tieBack set, to a garbage value. Start fiddling around; I can't give an exact recipe, but it should crash soon enough.

A "quick fix" might be to refuse to copy ties forward out of a selection. But if we do copy them, we need to figure out how to clean them up on undo. I am not sure connectTies() will do the trick, since the _tieBack values are garbage.