From 24c05a27f0198a70437d8888ab10b0a265a63381 Mon Sep 17 00:00:00 2001 From: lasconic Date: Mon, 10 Oct 2016 11:20:26 +0200 Subject: [PATCH] fix #136681: Corrupted scores with complex tuplet --- libmscore/measure.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/libmscore/measure.cpp b/libmscore/measure.cpp index f800b1d8c44d5..0b9059f684ab4 100644 --- a/libmscore/measure.cpp +++ b/libmscore/measure.cpp @@ -2031,14 +2031,20 @@ void Measure::checkMeasure(int staffIdx) int ticks = seg->tick() - stick; while (seg) { - if (ticks > 1) { - Fraction f = Fraction::fromTicks(ticks); - - Rest* rest = new Rest(score()); - rest->setDuration(f); - rest->setTrack(track); - rest->setGap(true); - score()->undoAddCR(rest, this, stick); + // !HACK, it was > 1, but for some tuplets it can happen to have 1 tick difference... + // 4 is a 512th... + if (ticks > 3) { + TDuration d; + d.setVal(ticks); + if (d.isValid()) { + Fraction f = Fraction::fromTicks(ticks); + Rest* rest = new Rest(score()); + rest->setDuration(f); + rest->setDurationType(d); + rest->setTrack(track); + rest->setGap(true); + score()->undoAddCR(rest, this, stick); + } } pseg = seg;