Skip to content

Commit

Permalink
Fix GH#24195: Crash in Tuplet::addMissingElements
Browse files Browse the repository at this point in the history
Backport of musescore#24201
  • Loading branch information
Jojo-Schmitz committed Aug 26, 2024
1 parent f2e67ca commit e945509
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libmscore/tuplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1325,14 +1325,18 @@ void Tuplet::addMissingElements()
{
if (tuplet())
return; // do not correct nested tuplets

if (voice() == 0)
return; // nothing to do for tuplets in voice 1

Fraction missingElementsDuration = ticks() * ratio() - elementsDuration();
if (missingElementsDuration.isZero())
return;
// first, fill in any holes in the middle of the tuplet
Fraction expectedTick = elements().front()->tick();
for (DurationElement* de : elements()) {

const std::vector<DurationElement*> elementsCopy = elements(); // mofified during loop
for (const DurationElement* de : elementsCopy) {
if (!de)
continue;
if (de->tick() != expectedTick) {
Expand All @@ -1342,6 +1346,7 @@ void Tuplet::addMissingElements()
}
expectedTick += de->actualTicks();
}

// calculate the tick where we would expect a tuplet of this duration to start
// TODO: check:
expectedTick = elements().front()->tick() - Fraction::fromTicks(elements().front()->tick().ticks() % ticks().ticks());
Expand Down

0 comments on commit e945509

Please sign in to comment.