CRASH if set Text size to 0
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.
Result:
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.
Comments
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?
opps, title wasn't completed.
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.)
In 2.1, the Style->Text QSpinBoxes already have their minimum set to 1, so I'm going to follow that precedent.
https://github.com/musescore/MuseScore/pull/3073
Note, I haven't fixed the crash...I've only prevented it from happening. Maybe someone else wants to investigate what happens when text size is 0. :)
(fyi, hypothetically text size could be set to 0 in CharFormat::setFormat()...I haven't asserted for that...)
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.
Fixed in branch master, commit 38db83523d
Merge pull request #3073 from ericfont/181701-TextToolsMinSize
fix #181701 TextTools spinbox minimum set to 1.
Automatically closed -- issue fixed for 2 weeks with no activity.