-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix crash when loading a certain MusicXML file #30698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2191,7 +2191,7 @@ void TLayout::layoutFermata(const Fermata* item, Fermata::LayoutData* ldata) | |
| double x = 0.0; | ||
| double y = item->placeAbove() ? 0.0 : item->staff()->staffHeight(item->tick()); | ||
| const Segment* s = item->segment(); | ||
| const EngravingItem* e = s->element(item->track()); | ||
| const EngravingItem* e = s ? s->element(item->track()) : nullptr; | ||
|
|
||
| if (e) { | ||
| LD_CONDITION(e->ldata()->isSetBbox()); // e->shape() | ||
|
|
@@ -2227,6 +2227,9 @@ void TLayout::layoutFermata(const Fermata* item, Fermata::LayoutData* ldata) | |
| if (item->isStyled(Pid::OFFSET)) { | ||
| y += item->offset().y(); | ||
| } | ||
| if (!item->segment()) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prevent dereferencing a nullptr. We might want to use IF_ASSERT_FAILED()` here |
||
| return; | ||
| } | ||
| Shape staffShape = item->segment()->staffShape(item->staffIdx()); | ||
| staffShape.removeTypes({ ElementType::FERMATA }); | ||
| if (item->placeAbove()) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5178,7 +5178,7 @@ void MusicXmlParserDirection::dashes(const String& type, const int number, | |
| { | ||
| const MusicXmlExtendedSpannerDesc& spdesc = m_pass2.getSpanner({ ElementType::HAIRPIN, number }); | ||
| if (type == u"start") { | ||
| TextLineBase* b = spdesc.isStopped ? toTextLine(spdesc.sp) : Factory::createTextLine(m_score->dummy()); | ||
| TextLineBase* b = spdesc.isStopped && spdesc.sp->isTextLine() ? toTextLine(spdesc.sp) : Factory::createTextLine(m_score->dummy()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prevent a crash in Debug builds |
||
| // if (placement.empty()) placement = "above"; // TODO ? set default | ||
|
|
||
| // hack: combine with a previous words element | ||
|
|
@@ -5202,7 +5202,7 @@ void MusicXmlParserDirection::dashes(const String& type, const int number, | |
| // use MusicXML specific type instead | ||
| starts.push_back(MusicXmlSpannerDesc(b, ElementType::TEXTLINE, number)); | ||
| } else if (type == u"stop") { | ||
| TextLine* b = spdesc.isStarted ? toTextLine(spdesc.sp) : Factory::createTextLine(m_score->dummy()); | ||
| TextLine* b = spdesc.isStarted && spdesc.sp->isTextLine() ? toTextLine(spdesc.sp) : Factory::createTextLine(m_score->dummy()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It so far didn't crash here, but I'd rather be consistent and safe than sorry... |
||
| stops.push_back(MusicXmlSpannerDesc(b, ElementType::TEXTLINE, number)); | ||
| } | ||
| m_e.skipCurrentElement(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prevent dereferencing a
nullptr. We might want to use IF_ASSERF_FAILED()` here