Skip to content

Commit 5389a13

Browse files
Merge pull request #27074 from RomanPudashkin/midi_export_crash_partial_ties
Fix #27073: Crash on MIDI export with score containing partial ties
2 parents 44fc6af + cceaf59 commit 5389a13

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/engraving/compat/midi/compatmidirenderinternal.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,8 @@ static int calculateTieLength(const Note* note)
631631
const Note* n = note;
632632
while (n) {
633633
// Process ties or bends
634-
Tie* tieFor = n->tieFor();
635-
GuitarBend* bendFor = n->bendFor();
634+
const Tie* tieFor = n->tieForNonPartial();
635+
const GuitarBend* bendFor = n->bendFor();
636636

637637
if (tieFor && tieFor->endNote() != n) {
638638
n = tieFor->endNote();
@@ -642,10 +642,14 @@ static int calculateTieLength(const Note* note)
642642
break;
643643
}
644644

645-
NoteEventList nel = n->playEvents();
645+
IF_ASSERT_FAILED(n) {
646+
break;
647+
}
648+
649+
const NoteEventList& nel = n->playEvents();
646650

647651
if (!nel.empty()) {
648-
tieLen += n->playEvents()[0].len() * n->chord()->actualTicks().ticks() / NoteEvent::NOTE_LENGTH;
652+
tieLen += nel[0].len() * n->chord()->actualTicks().ticks() / NoteEvent::NOTE_LENGTH;
649653
}
650654
}
651655

0 commit comments

Comments
 (0)