Skip to content

Commit

Permalink
Merge pull request #10646 from Jojo-Schmitz/capella-crash
Browse files Browse the repository at this point in the history
[MU4] Fix #329800: Crash on importing Capella .capx file
  • Loading branch information
cbjeukendrup committed Oct 13, 2023
2 parents f8122ac + dfd0e23 commit 2463930
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/engraving/dom/measure.cpp
Expand Up @@ -1265,6 +1265,9 @@ void Measure::insertStaff(Staff* staff, staff_idx_t staffIdx)
RectF Measure::staffabbox(staff_idx_t staffIdx) const
{
System* s = system();
IF_ASSERT_FAILED(s) {
return RectF();
}
RectF sb(s->staff(staffIdx)->bbox());
RectF rrr(sb.translated(s->pagePos()));
RectF rr(abbox());
Expand Down
22 changes: 11 additions & 11 deletions src/importexport/capella/internal/capella.cpp
Expand Up @@ -419,7 +419,7 @@ static bool findChordRests(BasicDrawObj const* const o, Score* score, const int
int graceNumber1 = 0;
bool foundcr1 = false;
Fraction tick2 = tick;
foreach (NoteObj* nobj, objects) {
for (NoteObj* nobj : objects) {
BasicDurationalObj* d = 0;
if (nobj->type() == CapellaNoteObjectType::REST) {
d = static_cast<BasicDurationalObj*>(static_cast<RestObj*>(nobj));
Expand Down Expand Up @@ -468,14 +468,14 @@ static bool findChordRests(BasicDrawObj const* const o, Score* score, const int
if (seg->segmentType() != SegmentType::ChordRest) {
continue;
}
ChordRest* cr = static_cast<ChordRest*>(seg->element(track));
ChordRest* cr = toChordRest(seg->element(track));
if (cr) {
if (graceNumber1 > 0) { // the spanner is starting from a grace note
Chord* chord = static_cast<Chord*>(cr);
foreach (Chord* cc, chord->graceNotes()) {
if ((graceNumber1 > 0) && cr->isChord()) { // the spanner is starting from a grace note
Chord* chord = toChord(cr);
for (Chord* cc : chord->graceNotes()) {
--graceNumber1;
if ((graceNumber1 == 0) && (!cr1)) {
cr1 = static_cast<ChordRest*>(cc); // found first ChordRest
cr1 = toChordRest(cc); // found first ChordRest
}
}
}
Expand All @@ -489,14 +489,14 @@ static bool findChordRests(BasicDrawObj const* const o, Score* score, const int
if (seg->segmentType() != SegmentType::ChordRest) {
continue;
}
ChordRest* cr = static_cast<ChordRest*>(seg->element(track));
ChordRest* cr = toChordRest(seg->element(track));
if (cr) {
if ((graceNumber > 0) && (cr->type() == ElementType::CHORD)) { // the spanner is ending on a grace note
Chord* chord = static_cast<Chord*>(cr);
foreach (Chord* cc, chord->graceNotes()) {
if ((graceNumber > 0) && cr->isChord()) { // the spanner is ending on a grace note
Chord* chord = toChord(cr);
for (Chord* cc : chord->graceNotes()) {
--graceNumber;
if ((graceNumber == 0) && (!cr2)) {
cr2 = static_cast<ChordRest*>(cc); // found 2nd ChordRest
cr2 = toChordRest(cc); // found 2nd ChordRest
}
}
}
Expand Down

0 comments on commit 2463930

Please sign in to comment.