Staff/Part properties >> Advanced Style Properties >> Stemless crashes MuseScore

• Mar 31, 2020 - 21:51
Reported version
3.x-dev
Type
Functional
Frequency
Once
Severity
S2 - Critical
Reproducibility
Always
Status
closed
Regression
Yes
Workaround
No
Project

Repro steps:
* Create a new score.
* Right click the staff and click Staff/Part properties
* Advanced Style Properties
* Check Stemless

Expected: The stems are hidden in the preview.
Actual: Crash


Comments

Status active needs info

I can't reproduce. You say you created a new score, but how exactly? Does fail with other scores too? Can you attach a specific score where it fails for you?

Reported version 3.4 3.x-dev

This is a self build from the end of last week. I also cannot reproduce it in 3.4 -> changed reported version.
- So it is a regression vs 3.4.
- It happens with each and any score, existing or new.

Status needs info active

Indeed. I can reproduce with the last nightly: OS: Windows 10 (10.0), Arch.: x86_64, MuseScore version (64-bit): 3.5.0.10755, revision: 1163513

This issue occurs on last February 10 or February 11.
- This nightly works: 32812a2
- This one crashes: 8079351
There is eight commits between them. Must be check where it's happening.

Stack trace:
1 Ms::Stem::lineWidthMag stem.h 66 0xf97a34
2 Ms::Beam::layout2 beam.cpp 1789 0x877ced
3 Ms::Beam::layout beam.cpp 542 0x86d910
4 Ms::Score::layoutSystemElements layout.cpp 3633 0x940386
5 Ms::LayoutContext::layoutLinear layoutlinear.cpp 206 0xb1f1f1
6 Ms::Score::layoutLinear layoutlinear.cpp 195 0xb1f184
7 Ms::Score::doLayoutRange layout.cpp 4436 0x945e9a
8 Ms::Score::doLayout layout.cpp 4347 0x945739
9 Ms::EditStaffType::updatePreview editstafftype.cpp 549 0x7d1ce4
10 Ms::EditStaffType::qt_static_metacall moc_editstafftype.cpp 114 0x62598b
11 QMetaObject::activate(QObject *, int, int, void * *) 0x68a947c8
12 QAbstractButton::toggled(bool) 0x2a16e4cb
13 QAbstractButton::setChecked(bool) 0x2a16f9d1
14 QCheckBox::nextCheckState() 0x2a17d0b8
15 QAbstractButton::setIconSize(QSize const&) 0x2a16f53d
16 QAbstractButton::mouseReleaseEvent(QMouseEvent *) 0x2a16f775
17 QWidget::event(QEvent *) 0x2a0d5f18
18 QApplicationPrivate::notify_helper(QObject *, QEvent *) 0x2a097bdc
19 QApplication::notify(QObject *, QEvent *) 0x2a09fc1a
20 QCoreApplication::sendSpontaneousEvent(QObject *, QEvent *) 0x68a694a8
...

Possible fix:

diff --git a/libmscore/beam.cpp b/libmscore/beam.cpp
index d1e6144ef..244d42711 100644
--- a/libmscore/beam.cpp
+++ b/libmscore/beam.cpp
@@ -1786,7 +1786,7 @@ void Beam::layout2(std::vector<ChordRest*>crl, SpannerSegmentType, int frag)
                               crBase[i1] = bl;
                         }
 
-                  qreal stemWidth  = cr1->isChord() ? toChord(cr1)->stem()->lineWidthMag() : 0.0;
+                  qreal stemWidth  = cr1->isChord() && toChord(cr1)->stem() ? toChord(cr1)->stem()->lineWidthMag() : 0.0;
                   qreal x2         = cr1->stemPosX() + cr1->pageX() - _pagePos.x();
                   qreal x3;
 
@@ -1803,7 +1803,7 @@ void Beam::layout2(std::vector<ChordRest*>crl, SpannerSegmentType, int frag)
                               if (cr1->up())
                                     x2 -= stemWidth;
                               if (!chordRest2->up())
-                                    x3 += chordRest2->isChord() ? toChord(chordRest2)->stem()->lineWidthMag() : 0.0;
+                                    x3 += chordRest2->isChord() && toChord(chordRest2)->stem() ? toChord(chordRest2)->stem()->lineWidthMag() : 0.0;
                               }
                         }
                   else {
Status PR created fixed

Fixed in branch master, commit 263d5d91d7

_fix #303189: Staff/Part properties > Advanced Style Properties > Stemless crashes MuseScore

The problem is that a stem's lineWidthMag() was asked for even if
there is no stem (anymore).

Apparently caused by the changes in #5669 / 57d8a1841 for fixing
#291699_

Fix version
3.5.0