Skip to content
Permalink
Browse files

fix #202271 : copy-paste of tuplets with non-reduced ratio

  • Loading branch information...
AntonioBL committed Mar 8, 2018
1 parent 5f6b17b commit 9e978c0b203927c73b63de65352b127372fb9f05
Showing with 6 additions and 7 deletions.
  1. +6 −7 libmscore/tuplet.cpp
@@ -688,8 +688,7 @@ void Tuplet::read(XmlReader& e)
else if (!DurationElement::readProperties(e))
e.unknown();
}
Fraction r = (_ratio == 1) ? _ratio : _ratio.reduced();
Fraction f(r.denominator(), _baseLen.fraction().denominator());
Fraction f(_ratio.denominator(), _baseLen.fraction().denominator());
setDuration(f.reduced());
if (bl != -1) { // obsolete
TDuration d;
@@ -981,11 +980,11 @@ QVariant Tuplet::propertyDefault(P_ID id) const

void Tuplet::sanitizeTuplet()
{
Fraction tupletDuration = duration().reduced();
Fraction baseLenDuration = (Fraction(ratio().denominator(),1) * baseLen().fraction()).reduced();
if ((tupletDuration - baseLenDuration).reduced().numerator() == 0)
if (ratio().numerator() == ratio().reduced().numerator()) // return if the ratio is an irreducible fraction
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
// durations of the elements constituting the tuplet. This does not work for
// not-completely filled tuplets, such as tuplets in voices > 0 with
@@ -1007,7 +1006,7 @@ void Tuplet::sanitizeTuplet()
}
testDuration = testDuration / ratio();
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());
f.reduce();
Fraction fbl(1, f.denominator());

0 comments on commit 9e978c0

Please sign in to comment.
You can’t perform that action at this time.