CRASH if set Text size to 0

• Mar 16, 2017 - 04:28
Reported version
S4 - Minor

On 3.0-dev bd894bd8d

Reproduction steps:

Double click any text, like composer text, select some or all of the characters, and then decrease text size to 0.


MuseScore is killed.

Note that the crash is not at Segfault, but rather MuseScore is simply killed without any error message.

Note that on 2.1-dev that setting text size to 0 will simply revert the text to appear in its initial default size.


MicroSoft WordPad won't let me set text size below 1. Will round up to 1. And if set to 0, it will set to previous value.

Maybe we need to prohibit setting value to 0?

QDoubleSpinBox::setMinimum() could be used. I'm wondering what the minimum should be: 0.01 or 0.1 or 1?

Alternatively, or in addition, CharFormat::setFontSize() could (or should?) assert for val > 0.0.

I'm going to to both:
- set the spinbox's minimum to .01 (why would anyone want it smaller than that? Maybe if printing a score on a grain of rice?)
- have a Q_ASSERT in CharFormat::setFontSize(), which is useful because assert failure will crash but will at least produce a meaningful error message to console.

Well, actually size 1 is probably pretty small, honestly. It is same size as the width of the dotted blue line around the title box:


And is readable at zoom %1600. While .01 would not possibly be readable even at that zoom.

And the nice thing about size 1 is that when decrease to that and then increase, won't have the .01 leftover (like 1.01, 2.01, etc.)

Status (old) patch (code needs review) fixed

Fixed in branch master, commit bf00271a65

fix #181701 TextTools spinbox minimum set to 1.

This prevents a bug in 3.0 whereby musescore would be killed if set text size to 0.

I also put in a Q_ASSERT into CharFormat::setFontSize() to ensure FontSize is positive real.