Zero font size in XML crashes 3.6 on import

• Jan 9, 2021 - 03:50

I stumbled across this taking input from SmartScore. For reasons unknown (but I would think wrong) they generate text at times with zero font size.

When I compiled 3.6, this zero font siez causes an assert abort in textbase.h at line 91.

The actual posted 3.6RC compilation does not abort -- not sure if that's because some debug/asserts are turned off?

I am not quite sure what it should do -- maybe the assert/abort and production non-abort is right.

But here is a contrived very small example that will trigger it if interested; the version from Smartscore was very long. I just edit out the font-size zeros now in their xml. It doesn't do it all the time, but I have had it do it twice in the last 8 or so scores converted.

For what it is worth.

Linwood

PS. Just to be clear -- this file was hand edited to include the font size of zero. It was produced from Musescore not Smartscore, so I could get a small file. This is not reporting a bug in producing XML with zero sizes, but importing.

Attachment Size
Demonstrate zero size font.musicxml 7.59 KB

Comments

Debug builds have those asserts enabled, non-debug builds have not, that should explain why Debug builds die on them and non-debug builds do not, at least not at that spot.

libmscore/textbase.cpp, line 91:

      void setFontSize(qreal val)            { Q_ASSERT(val > 0.0); _fontSize = val; }

Maybe we could allow for >= 0.0? But then it might crash (fail an assertion) in libmscore/textline.cpp, line 882:

      Q_ASSERT(m > 0.0);

so would need to allow it there too.

The xml code:

      <direction placement="above">
        <direction-type>
          <words default-y="3.45" relative-y="10.00"   font-size="0">Staff Text</words>
          </direction-type>
        <staff>1</staff>
        </direction>
 

Interesting that size is getting ignored when importing into 3.5.2 or 3.6RC and set to 10.
While I don't see any negative effects when allowing for 0.0, there's debug output that warns about this:
Warning: QFont::setPointSizeF: Point size <= 0 (0.000000), must be greater than 0 (:0, )

In reply to by Jojo-Schmitz

It looks like the MusicXML importer does not contain a lot of checks for font size, I found a single > 0 check in importexport/musicxml/importmxmlpass1.cpp and importmxmlpass2.cpp.

As typical font sizes are between about 5 and 25, adding more checks in the importer would prevent the crash. A smallish value like 0.1 should be good enough and not overly restrictive. Comparing floats with exactly 0 is never a good idea anyway.

In reply to by Jojo-Schmitz

I am not engaged in active Musescore development so I posted this so people who are can make that sort of decision, since it happened in real world imports (but with a development version). I looked in the non-debug result and it looks like it defaulted to a 10pt text (whether fixed or inherited I did not try to figure out).

Do you still have an unanswered question? Please log in first to post your question.