Crash on copy/paste with mmrests

• Aug 27, 2015 - 20:01
Type
Functional
Severity
S2 - Critical
Status
closed
Project

Hello!

1. Open the score named "test" attached to this post.

2. Select all the 2 first trumpets (in C) (click on the first measure of the first trip, hold "shift", and click on the last measure of the second trp.

3. Copy the selection

4. Click on the first measure of the Third trumpet (in Bb)

And MuseScore crashes.

OSX Yosemite 10.10.4
MuseScore 2.0.2 f51dc11
Qt version 5.4.2

Attachment Size
test.mscz 28.82 KB

Comments

Confirmed. The problem has to do with the mmrests, and will happen only if mmrests have been on the whole session - turning them off then on again prevents the crash.

The crash happens when we are trying to draw the selection rectangle and fail to notice that the measure for the start segment has not been laid out yet, because it is in a measure that is itself with an mmrest. In this sense it is very much like #51876: Crash navigating into multimeasure rest using Measure Properties and perhaps a coupe of other related problems that were fixed earlier.

A minimal crash: open this file: mmrests test.mscz
Copy and past the "second" measure with MM rests of the first staff onto the same measure of the second staff.
Result: crash (if not the first time, retry and the crash occurs)
From what I see, this operation has always failed, not a surprise I suppose, as far as I go back in time since fifteen months.

EDIT: a precision: "crash (if not the first time, retry and the crash occurs)" : I wanted saying after Save and Reload the file.

Status (old) active patch (code needs review)

https://github.com/musescore/MuseScore/pull/2192 fixes the crash, and shouldn't cause any other problems since it doesn't really change anything except how we draw the selection rectangle in this specific case.

Oddly, though, in testing this, I discovered another crash that does not seem related at all. To reproduce using the same file:

1) select measures 3-6 on the top staff (the group of measures between the first two mmrests)
2) ctrl+c to copy
3) click measure 3 of second staff
4) paste

Result: crash (again, only if you do this right after loading the file, it is prevented if you toggle mmrests off then on again).

EDIT:

At first glance the cause seems entirely unrelated. The crash happens when processing and endSpanner tag for which the spanner itself has been deleted. I managed to track it down to this code:

https://github.com/musescore/MuseScore/blob/f07d7bb52b8492917198a87a653…

As I recall, this code was put into place to prevent copy of ties that start inside the selected region but end outside it. I can't see any reason that code would be in play at all here, but somehow the tick calculation we are testing here is getting fooled. Anyhow, it does not *seem* related to the original problem here, but maybe it will turn out to be, I don't know.

The tie in question is in measure 68, I think. I'm guessing maybe we aren't correctly detecting we have reached the end of the selection, because the next segment is in measure that hasn't been laid out yet because it is in an mmrest, so related in that sense, but the fix will be somewhere else.