Crash when loading style
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.
I apologize for being inpatient, but the new features are so great that I can't stop myself from using v3.0.
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.
Fixed in branch master, commit 19cabce46f
fix #118341
Automatically closed -- issue fixed for 2 weeks with no activity.