diff --git a/libmscore/paste.cpp b/libmscore/paste.cpp index 2b4a66f5ef..ae991dfd52 100644 --- a/libmscore/paste.cpp +++ b/libmscore/paste.cpp @@ -420,30 +420,14 @@ void Score::pasteChordRest(ChordRest* cr, int tick, const Interval& srcTranspose // split Chord Chord* c = static_cast(cr); int rest = c->actualTicks(); - int len = measureEnd - tick; - rest -= len; - TDuration d; - d.setVal(len); - c->setDurationType(d); - c->setDuration(d.fraction()); - undoAddCR(c, measure, tick); + bool firstpart = true; while (rest) { - tick += c->actualTicks(); measure = tick2measure(tick); - //if (measure->tick() != tick) { // last measure - // qDebug("==last measure %d != %d", measure->tick(), tick); - // break; - // } Chord* c2 = static_cast(c->clone()); - len = measure->ticks() > rest ? rest : measure->ticks(); - TDuration d; - d.setVal(len); - // split the remaining part of the chord in the final target measure - // into a set of valid value chords - if (len == rest) { - QList dl = toDurationList(Fraction::fromTicks(len), true); - d = dl[0]; - } + int mlen = measure->tick() + measure->ticks() - tick; + int len = mlen > rest ? rest : mlen; + QList dl = toDurationList(Fraction::fromTicks(len), true); + TDuration d = dl[0]; c2->setDurationType(d); c2->setDuration(d.fraction()); rest -= c2->actualTicks(); @@ -452,20 +436,23 @@ void Score::pasteChordRest(ChordRest* cr, int tick, const Interval& srcTranspose QList nl1 = c->notes(); QList nl2 = c2->notes(); - for (int i = 0; i < nl1.size(); ++i) { - Tie* tie = new Tie(this); - tie->setStartNote(nl1[i]); - tie->setEndNote(nl2[i]); - tie->setTrack(c->track()); - Tie* tie2 = nl1[i]->tieFor(); - if (tie2) { - nl2[i]->setTieFor(nl1[i]->tieFor()); - tie2->setStartNote(nl2[i]); + if (!firstpart) + for (int i = 0; i < nl1.size(); ++i) { + Tie* tie = new Tie(this); + tie->setStartNote(nl1[i]); + tie->setEndNote(nl2[i]); + tie->setTrack(c->track()); + Tie* tie2 = nl1[i]->tieFor(); + if (tie2) { + nl2[i]->setTieFor(nl1[i]->tieFor()); + tie2->setStartNote(nl2[i]); + } + nl1[i]->setTieFor(tie); + nl2[i]->setTieBack(tie); } - nl1[i]->setTieFor(tie); - nl2[i]->setTieBack(tie); - } c = c2; + firstpart = false; + tick += c->actualTicks(); } } else { @@ -478,13 +465,8 @@ void Score::pasteChordRest(ChordRest* cr, int tick, const Interval& srcTranspose measure = tick2measure(tick); Fraction mlen = Fraction::fromTicks(measure->tick() + measure->ticks() - tick); Fraction len = rest > mlen ? mlen : rest; - TDuration d = TDuration(len); - // split the remaining part of the rest in the final target measure - // into a set of valid value rests - if (len == rest) { - QList dl = toDurationList(len, true); - d = dl[0]; - } + QList dl = toDurationList(len, false); + TDuration d = dl[0]; r2->setDuration(d.fraction()); r2->setDurationType(d); undoAddCR(r2, measure, tick); diff --git a/mtest/libmscore/copypaste/copypaste17-ref.mscx b/mtest/libmscore/copypaste/copypaste17-ref.mscx index 203231e4ec..599961619b 100644 --- a/mtest/libmscore/copypaste/copypaste17-ref.mscx +++ b/mtest/libmscore/copypaste/copypaste17-ref.mscx @@ -196,9 +196,12 @@ 1 - 1 quarter + + 1 + eighth +