Skip to content

Commit

Permalink
Fix #301016: Copying a partial measure leaves rest(s) missing in voic…
Browse files Browse the repository at this point in the history
…es 2-4

Resolves: https://musescore.org/en/node/301016.

Rebased version of #5702
  • Loading branch information
mattmcclinch authored and igorkorsukov committed Apr 11, 2021
1 parent f198f88 commit f2092fa
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/libmscore/check.cpp
Expand Up @@ -334,7 +334,7 @@ bool Score::checkClefs()
// fillGap
//---------------------------------------------------------

void Measure::fillGap(const Fraction& pos, const Fraction& len, int track, const Fraction& stretch)
void Measure::fillGap(const Fraction& pos, const Fraction& len, int track, const Fraction& stretch, bool useGapRests)
{
qDebug("measure %6d pos %d, len %d/%d, stretch %d/%d track %d",
tick().ticks(),
Expand All @@ -349,7 +349,7 @@ void Measure::fillGap(const Fraction& pos, const Fraction& len, int track, const
rest->setTicks(len);
rest->setDurationType(d);
rest->setTrack(track);
rest->setGap(true);
rest->setGap(useGapRests);
score()->undoAddCR(rest, this, (pos / stretch) + tick());
}
}
Expand All @@ -361,7 +361,7 @@ void Measure::fillGap(const Fraction& pos, const Fraction& len, int track, const
// with invisible rests
//---------------------------------------------------------

void Measure::checkMeasure(int staffIdx)
void Measure::checkMeasure(int staffIdx, bool useGapRests)
{
if (isMMRest()) {
return;
Expand Down Expand Up @@ -392,7 +392,7 @@ void Measure::checkMeasure(int staffIdx)
} else if (currentPos > expectedPos) {
qDebug("in measure underrun %6d at %d-%d track %d", tick().ticks(),
(currentPos / stretch).ticks(), (expectedPos / stretch).ticks(), track);
fillGap(expectedPos, currentPos - expectedPos, track, stretch);
fillGap(expectedPos, currentPos - expectedPos, track, stretch, useGapRests);
}

DurationElement* de = cr;
Expand Down
4 changes: 2 additions & 2 deletions src/libmscore/measure.h
Expand Up @@ -147,7 +147,7 @@ class Measure final : public MeasureBase
void writeBox(XmlWriter&) const;
void readBox(XmlReader&);
bool isEditable() const override { return false; }
void checkMeasure(int idx);
void checkMeasure(int idx, bool useGapRests = true);

void add(Element*) override;
void remove(Element*) override;
Expand Down Expand Up @@ -334,7 +334,7 @@ class Measure final : public MeasureBase
void push_back(Segment* e);
void push_front(Segment* e);

void fillGap(const Fraction& pos, const Fraction& len, int track, const Fraction& stretch);
void fillGap(const Fraction& pos, const Fraction& len, int track, const Fraction& stretch, bool useGapRests = true);
void computeMinWidth(Segment* s, qreal x, bool isSystemHeader);

void readVoice(XmlReader& e, int staffIdx, bool irregular);
Expand Down
2 changes: 1 addition & 1 deletion src/libmscore/paste.cpp
Expand Up @@ -499,7 +499,7 @@ bool Score::pasteStaff(XmlReader& e, Segment* dst, int dstStaff, Fraction scale)
Measure* endM = tick2measure(dstTick + tickLen);
for (int i = dstStaff; i < endStaff; i++) {
for (Measure* m = dstM; m && m != endM->nextMeasure(); m = m->nextMeasure()) {
m->checkMeasure(i);
m->checkMeasure(i, false);
}
}
_selection.setRangeTicks(dstTick, dstTick + tickLen, dstStaff, endStaff);
Expand Down
3 changes: 3 additions & 0 deletions src/libmscore/tests/copypaste_data/copypaste14-ref.mscx
Expand Up @@ -180,6 +180,9 @@
<tpc>14</tpc>
</Note>
</Chord>
<Rest>
<durationType>half</durationType>
</Rest>
</voice>
</Measure>
<Measure>
Expand Down
3 changes: 3 additions & 0 deletions src/libmscore/tests/copypaste_data/copypaste15-ref.mscx
Expand Up @@ -180,6 +180,9 @@
<tpc>18</tpc>
</Note>
</Chord>
<Rest>
<durationType>half</durationType>
</Rest>
</voice>
</Measure>
<Measure>
Expand Down
3 changes: 3 additions & 0 deletions src/libmscore/tests/copypaste_data/copypaste16-ref.mscx
Expand Up @@ -163,6 +163,9 @@
<tpc>18</tpc>
</Note>
</Chord>
<Rest>
<durationType>half</durationType>
</Rest>
</voice>
</Measure>
<Measure>
Expand Down
3 changes: 3 additions & 0 deletions src/libmscore/tests/copypaste_data/copypaste21-ref.mscx
Expand Up @@ -178,6 +178,9 @@
<tpc>18</tpc>
</Note>
</Chord>
<Rest>
<durationType>half</durationType>
</Rest>
</voice>
</Measure>
<Measure>
Expand Down
6 changes: 6 additions & 0 deletions src/libmscore/tests/copypaste_data/copypaste_tremolo-ref.mscx
Expand Up @@ -178,6 +178,9 @@
<tpc>18</tpc>
</Note>
</Chord>
<Rest>
<durationType>half</durationType>
</Rest>
</voice>
</Measure>
<Measure>
Expand Down Expand Up @@ -229,6 +232,9 @@
<tpc>13</tpc>
</Note>
</Chord>
<Rest>
<durationType>quarter</durationType>
</Rest>
</voice>
</Measure>
<Measure>
Expand Down

0 comments on commit f2092fa

Please sign in to comment.