Crash on startup if displaying Start Center with 1.3 scores

• Feb 17, 2016 - 23:12
Type
Functional
Severity
S2 - Critical
Status
closed
Project

Ubuntu 14.04, GIT commit: 28303e0

See my comments in https://musescore.org/en/node/95826#comment-438301 and below for background. This is related, I assume, to the change to make Text:_cursor not be a static member but instead be a regular member, and dynamically allocated at that. The following steps are reproducible for me in my self-build, but even if they don't reproduce for someone else, I think we can probbably identify the cause and fix it.

1) start MuseScore with "-F"
2) load a 1.3 score
3) close MsueScore
4) restart MuseScore

For me, it crashes in Text::changeSelectionFormat(), which is being called during the generation of a thumbnail for my 1.3 score to display in the Start Center. The root cause of the crash appears to be that TextTools::fontChanged() is being called during the course of the initialization for the score font, but TextTools::_textElement is null. This was probably true before the aforementioned change as well, but we were getting away with it, I think, because Text::_cursor was a static member and thus it didn't matter in Text::changeSelectionFormat() is "this" was null. Presumably, we were seeing that _cursor.hasSelection() was false and thus we would return right away with no harm done. Now that _cursor is not static, however, we need "this" and "_cursor" to both be valid.

The quick fix, I guess, is to test for null _textElement in TextTools::fontChanged(). Really, this should have been the case already; like I said, I think we were just getting lucky that Text::fontChanged didn't need "this" to be valid and that _cursor was static. Probably wouldn't hurt to test for null _cursor in Text::changeSelectionFormat() either.

We could also investigate why TextTools::fontChanged is being called at. It happens for me when trying to draw the first symbol of the 1.3 score (to generate the thumbnail) - we try to load the font, and somewhere or other within Qt, this triggers a callback for TextTools::qt_static_metacall(). It doesn't really make sense to me that we'd be doing this, but maybe that's just how it is. I'll let someone else sort that out.


Comments