From 7c3856551d4e17f36ff074e3337df6f1d206532f Mon Sep 17 00:00:00 2001 From: AntonioBL Date: Wed, 8 Oct 2014 13:42:34 +0200 Subject: [PATCH 1/2] fix #35851 : paste a chordrest crossing the barline of an irregular measure --- libmscore/paste.cpp | 62 ++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 40 deletions(-) diff --git a/libmscore/paste.cpp b/libmscore/paste.cpp index 9c8135facdec..effb0d466999 100644 --- a/libmscore/paste.cpp +++ b/libmscore/paste.cpp @@ -418,30 +418,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(); @@ -450,20 +434,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 { @@ -476,13 +463,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); From 57dc1bef037fe6ddf74fda7e1825601a09ea7755 Mon Sep 17 00:00:00 2001 From: AntonioBL Date: Thu, 9 Oct 2014 11:06:40 +0200 Subject: [PATCH 2/2] update copypaste test --- mtest/libmscore/copypaste/copypaste17-ref.mscx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mtest/libmscore/copypaste/copypaste17-ref.mscx b/mtest/libmscore/copypaste/copypaste17-ref.mscx index 203231e4ec42..599961619b42 100644 --- a/mtest/libmscore/copypaste/copypaste17-ref.mscx +++ b/mtest/libmscore/copypaste/copypaste17-ref.mscx @@ -196,9 +196,12 @@ 1 - 1 quarter + + 1 + eighth +