diff --git a/libmscore/edit.cpp b/libmscore/edit.cpp index 35ad6bdad1..2125edab12 100644 --- a/libmscore/edit.cpp +++ b/libmscore/edit.cpp @@ -2895,7 +2895,7 @@ void Score::nextInputPos(ChordRest* cr, bool doSelect) // If measure is zero, append new MeasureBase. //--------------------------------------------------------- -void Score::insertMeasure(ElementType type, MeasureBase* measure, bool createEmptyMeasures) +void Score::insertMeasure(ElementType type, MeasureBase* measure, bool createEmptyMeasures, bool moveSignaturesClef) { Fraction tick; if (measure) { @@ -2972,7 +2972,7 @@ void Score::insertMeasure(ElementType type, MeasureBase* measure, bool createEmp // // remove clef, time and key signatures // - if (mi) { + if (moveSignaturesClef && mi) { for (int staffIdx = 0; staffIdx < score->nstaves(); ++staffIdx) { Measure* pm = mi->prevMeasure(); if (pm) { diff --git a/libmscore/score.h b/libmscore/score.h index 51b2c89fe9..52bde21920 100644 --- a/libmscore/score.h +++ b/libmscore/score.h @@ -1087,7 +1087,7 @@ class Score : public QObject, public ScoreElement { void cmdSelectSection(); void respace(std::vector* elements); void transposeSemitone(int semitone); - void insertMeasure(ElementType type, MeasureBase*, bool createEmptyMeasures = false); + void insertMeasure(ElementType type, MeasureBase*, bool createEmptyMeasures = false, bool moveSignaturesClef = true); Audio* audio() const { return _audio; } void setAudio(Audio* a) { _audio = a; } PlayMode playMode() const { return _playMode; } diff --git a/libmscore/splitMeasure.cpp b/libmscore/splitMeasure.cpp index d5a4c371ac..94640e0c4f 100644 --- a/libmscore/splitMeasure.cpp +++ b/libmscore/splitMeasure.cpp @@ -17,7 +17,9 @@ #include "range.h" #include "tuplet.h" #include "spanner.h" +#include "tie.h" #include "undo.h" +#include "utils.h" namespace Ms { @@ -70,14 +72,27 @@ void Score::splitMeasure(Segment* segment) sl.push_back(make_tuple(s, s->tick(), s->ticks())); } + // Make sure ties are the beginning the split measure are restored. + std::vector ties; + for (int track = 0; track < ntracks(); track++) { + Chord* chord = measure->findChord(stick, track); + if (chord) + for (Note* note : chord->notes()) { + Tie* tie = note->tieBack(); + if (tie) + ties.push_back(tie->clone()); + } + } + MeasureBase* nm = measure->next(); + undoRemoveMeasures(measure, measure); undoInsertTime(measure->tick(), -measure->ticks()); // create empty measures: - insertMeasure(ElementType::MEASURE, nm, true); + insertMeasure(ElementType::MEASURE, nm, true, false); Measure* m2 = toMeasure(nm ? nm->prev() : lastMeasure()); - insertMeasure(ElementType::MEASURE, m2, true); + insertMeasure(ElementType::MEASURE, m2, true, false); Measure* m1 = toMeasure(m2->prev()); Fraction tick = segment->tick(); @@ -91,6 +106,12 @@ void Score::splitMeasure(Segment* segment) m2->adjustToLen(ticks2.reduced(), false); range.write(this, m1->tick()); + // Restore ties the the beginning of the split measure. + for (auto tie : ties) { + tie->setEndNote(searchTieNote(tie->startNote())); + undoAddElement(tie); + } + for (auto i : sl) { Spanner* s = std::get<0>(i); Fraction t = std::get<1>(i); diff --git a/mtest/libmscore/split/split295207-ref.mscx b/mtest/libmscore/split/split295207-ref.mscx new file mode 100644 index 0000000000..a87893cb2a --- /dev/null +++ b/mtest/libmscore/split/split295207-ref.mscx @@ -0,0 +1,283 @@ + + + + + 0 + 480 + + 1 + 1 + 1 + 0 + + + + + + + + + + + Test + + + + stdNormal + + + Voice + + Voice + 36 + 94 + 40 + 79 + + 100 + 100 + + + 100 + 85 + + + 100 + 100 + + + 120 + 100 + + + + + + + + 10 + + + Test + + + + Split Measure within Time Signature change + + + + + + G + G + + + 4 + 4 + + + quarter + + 60 + 14 + + + + quarter + + 62 + 16 + + + + + 1 + + + + 3 + + + + + quarter + + + + + + 1 + -1/2 + + + + + 64 + 18 + + + + quarter + + + + + + + 1 + -3/4 + + + + 65 + 13 + + + + + + + + 2 + 4 + + + quarter + + + + -1 + 1/2 + + + + + + + + -1 + 3/4 + + + + 65 + 13 + + + + + + + + quarter + + + + + + 1 + 1/4 + + + + + + + + + + 1 + + + + 67 + 15 + + + + + + + + 2 + + + 4 + 4 + + + quarter + + + + + + 1/4 + + + + + + + + -1 + + + + 67 + 15 + + + + quarter + + + + -1 + -1/4 + + + + + + + -1/4 + + + + + 69 + 17 + + + + + + -3 + + + + + quarter + + 71 + 19 + + + + quarter + + + accidentalNatural + + 72 + 14 + + + + + + + diff --git a/mtest/libmscore/split/split295207.mscx b/mtest/libmscore/split/split295207.mscx new file mode 100644 index 0000000000..386895a176 --- /dev/null +++ b/mtest/libmscore/split/split295207.mscx @@ -0,0 +1,263 @@ + + + + + 0 + 480 + + 1 + 1 + 1 + 0 + + + + + + + + + + + Test + + + + stdNormal + + + Voice + + Voice + 36 + 94 + 40 + 79 + + 100 + 100 + + + 100 + 85 + + + 100 + 100 + + + 120 + 100 + + + + + + + + 10 + + + Test + + + + Split Measure within Time Signature change + + + + + + G + G + + + 4 + 4 + + + quarter + + 60 + 14 + + + + quarter + + 62 + 16 + + + + + 1 + + + + 2 + + + + + quarter + + + + + + 1 + -1/2 + + + + + 64 + 18 + + + + quarter + + + + + + + 1 + -3/4 + + + + 65 + 13 + + + + + + + + 2 + 4 + + + quarter + + + + -1 + 1/2 + + + + + + + + -1 + 3/4 + + + + 65 + 13 + + + + quarter + + + + + + 1 + + + + + + + + + + 1 + -1/4 + + + + 67 + 15 + + + + + + + + 2 + + + 4 + 4 + + + quarter + + + + + -1 + 1/4 + + + + 67 + 15 + + + + quarter + + + + -1 + + + + + 69 + 17 + + + + + + -2 + + + + + quarter + + 71 + 19 + + + + quarter + + + accidentalNatural + + 72 + 14 + + + + + + + diff --git a/mtest/libmscore/split/tst_split.cpp b/mtest/libmscore/split/tst_split.cpp index 71074b3270..7ecc8b4f89 100644 --- a/mtest/libmscore/split/tst_split.cpp +++ b/mtest/libmscore/split/tst_split.cpp @@ -58,6 +58,7 @@ class TestSplit : public QObject, public MTest split("split184061-keep-tie-before-break-voice-4.mscx", "split184061-keep-tie-before-break-voice-4-ref.mscx", 2); // splitting 1/64th after middle of measure...voice 4 already has a tie that need to be preserved after splitting, and voice 2 has whole note that must be split up with triple-dotted split("split184061-other-inst-only-one-tie.mscx", "split184061-other-inst-only-one-tie-ref.mscx", 2); // only the one tied note of the chord in the flute should still be tied over } + void split295207() { split("split295207.mscx", "split295207-ref.mscx", 5) ; } }; //---------------------------------------------------------