Crash when loading style

• Jul 15, 2016 - 16:17
Reported version
3.0
Type
Functional
Severity
S2 - Critical
Status
closed
Project

MuseScore crashs when you try to load a style from a file. Reason: When calling the function MStyle::set() (in style.cpp ln. 644) the member '_precomputedValues' is not initialized correctly (size == 0). So

if (!strcmp(styleTypes[idx].valueType(), "Ms::Spatium"))
_precomputedValues[idx] = _values[idx].value().val() * _spatium;

causes a crash.

A workaround is

if (!strcmp(styleTypes[idx].valueType(), "Ms::Spatium"))
{
if(_precomputedValues.size() == 0)
_precomputedValues.resize(247); // = number of Styles, to be sure
_precomputedValues[idx] = _values[idx].value().val() * _spatium;
}

Maybe someone will be faster than me finding the best place for correct initialization.


Comments

The reason is that within the copy constructor and the operator= of MStyle (style.cpp ln. 543 ff.) copying of _precomputedValues was forgotten.

With

//---------------------------------------------------------
// MStyle
//---------------------------------------------------------

MStyle::MStyle(const MStyle& s)
{
_values = s._values;
_precomputedValues = s._precomputedValues; // add this line
_chordList = s._chordList;
_textStyles = s._textStyles;
_pageFormat.copy(s._pageFormat);
_customChordList = s._customChordList;
}

MStyle& MStyle::operator=(const MStyle& s)
{
_values = s._values;
_precomputedValues = s._precomputedValues; // add this line
_chordList = s._chordList;
_textStyles = s._textStyles;
_pageFormat.copy(s._pageFormat);
_customChordList = s._customChordList;
return *this;
}

everything is ok.

I don't want to be rude and hurry you, but I would really appreciate fixing that bug since managing styles is quite crucial feature.

Keep in mind these very early experimental 3.0 builds are *not* meant for real use; they are for testing only. So yes of course it is crucial to fix before the eventual release, but please do not expect stability at this point, or indeed at any point in the near future.

Be aware that scores you create with current builds will very likely *not* continue to be openable in future builds. The changes still being made are of such a nature that we cannot guarantee backwards compatibility. So feel free to use it for scores you don't expect to need to access a month or a year from now, but take these warning about the experimental nature of the builds very seriously.