Crash when opening score with fermata

• Jul 28, 2018 - 13:51
Reported version
3.0
Type
Functional
Severity
S2 - Critical
Status
closed
Project
  1. Open attached score (produced in 2.3.1).

Result: Crash (see attached log).

Using MuseScore 3.0 Nightly 44debd7 - Mac 10.11.6.


Comments

I narrowed a large score down to this excerpt.

After some testing, it only seems to happen if there is a full voice 1 rest and fermata is multi-voice, though I stand open to correction.

It sees that on July 24, 2018 this code in Fermata::layout() was changed from

Element* e = s->element(track());
if (e && !e->isChord())
      x = e->x() + e->width() * staff()->mag(0) * .5;
else
      x = score()->noteHeadWidth() * staff()->mag(0) * .5;

to

Element* e = s->element(track());
if (e && e->isChord())
      x = score()->noteHeadWidth() * staff()->mag(0) * .5;
else
      x = e->x() + e->width() * staff()->mag(0) * .5;

Which means that if e is NULL, it will always be dereferenced. I am not sure what was wrong with the way it was before, but it could be changed to

Element* e = s->element(track());
if (!e || e->isChord())
      x = score()->noteHeadWidth() * staff()->mag(0) * .5;
else
      x = e->x() + e->width() * staff()->mag(0) * .5;

In the original score, the fermata was in voice 2. Upon import, it was changed to voice 1, which is why e was NULL in the first place. This is due to the following line at the end of readArticulation() in read206.cpp:

el->setTrack(cr->staffIdx() * VOICES);

It seems to me that instead the line should be:

el->setTrack(cr->track());

This would give the fermata the voice it had in the original score, and it would allow Fermata::layout() to find the element in the segment to which the fermata belongs.