Skip to content

Commit

Permalink
fix #202271 : copy-paste of tuplets with non-reduced ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioBL authored and lasconic committed Mar 10, 2018
1 parent d541fbc commit e1110cf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libmscore/tuplet.cpp
Expand Up @@ -1175,11 +1175,11 @@ void Tuplet::styleChanged()


void Tuplet::sanitizeTuplet() void Tuplet::sanitizeTuplet()
{ {
Fraction tupletDuration = duration().reduced(); if (ratio().numerator() == ratio().reduced().numerator()) // return if the ratio is an irreducible fraction
Fraction baseLenDuration = (Fraction(ratio().denominator(),1) * baseLen().fraction()).reduced();
if ((tupletDuration - baseLenDuration).reduced().numerator() == 0)
return; return;
// Mismatch between the duration and the duration computed from the base length. Fraction baseLenDuration = (Fraction(ratio().denominator(),1) * baseLen().fraction()).reduced();
// Due to a bug present in 2.1 (and before), a tuplet with non-reduced ratio could be
// in a corrupted state (mismatch between duration and base length).
// A tentative will now be made to retrieve the correct duration by summing up all the // A tentative will now be made to retrieve the correct duration by summing up all the
// durations of the elements constituting the tuplet. This does not work for // durations of the elements constituting the tuplet. This does not work for
// not-completely filled tuplets, such as tuplets in voices > 0 with // not-completely filled tuplets, such as tuplets in voices > 0 with
Expand All @@ -1201,7 +1201,7 @@ void Tuplet::sanitizeTuplet()
} }
testDuration = testDuration / ratio(); testDuration = testDuration / ratio();
testDuration.reduce(); testDuration.reduce();
if (((testDuration - tupletDuration).reduced().numerator() != 0) || ((testDuration - baseLenDuration).reduced().numerator() != 0)) { if ((testDuration - baseLenDuration).reduced().numerator() != 0) {
Fraction f = testDuration * Fraction(1, ratio().denominator()); Fraction f = testDuration * Fraction(1, ratio().denominator());
f.reduce(); f.reduce();
Fraction fbl(1, f.denominator()); Fraction fbl(1, f.denominator());
Expand Down

0 comments on commit e1110cf

Please sign in to comment.