Skip to content

Commit

Permalink
fix #24350: markings lost after timesig change
Browse files Browse the repository at this point in the history
Annotations were completely lost, spanners placed incorrectly.  Also,
repeat measure symbol caused hang.  These are fixed.  Key signatures
still can get messed up, at least until reload.  And barline styles are
lost even when they coincide.
  • Loading branch information
MarcSabatella committed Jan 21, 2014
1 parent 6dffde5 commit eec88fd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions libmscore/edit.cpp
Expand Up @@ -428,6 +428,7 @@ bool Score::rewriteMeasures(Measure* fm, Measure* lm, const Fraction& ns)
nfm->setPrev(fm->prev());
nlm->setNext(lm->next());
undo(new InsertMeasures(nfm, nlm));
range.fixup(nfm);
return true;
}

Expand Down
1 change: 1 addition & 0 deletions libmscore/joinMeasure.cpp
Expand Up @@ -43,6 +43,7 @@ void Score::cmdJoinMeasure(Measure* m1, Measure* m2)
}
m->setLen(f);
range.write(0, m);
range.fixup(m);

endCmd();
}
Expand Down
23 changes: 17 additions & 6 deletions libmscore/range.cpp
Expand Up @@ -69,7 +69,7 @@ void TrackList::append(Element* e)
&& back()->type() == Element::REST;
Segment* s = accumulateRest ? static_cast<Rest*>(e)->segment() : 0;

if (s && !s->score()->isSpannerStartEnd(s->tick(), e->track())) {
if (s && !s->score()->isSpannerStartEnd(s->tick(), e->track()) && !s->annotations().size()) {
// akkumulate rests
Rest* rest = static_cast<Rest*>(back());
Fraction d = rest->duration();
Expand Down Expand Up @@ -166,6 +166,9 @@ void TrackList::read(int track, const Segment* fs, const Segment* es)
}
else if (e->type() == Element::BAR_LINE)
;
// else if (e->type() == Element::REPEAT_MEASURE) {
// // TODO: copy previous measure contents?
// }
else
append(e);
}
Expand Down Expand Up @@ -318,7 +321,7 @@ bool TrackList::write(int track, Measure* measure) const
//

while (duration.numerator() > 0) {
if (e->type() == Element::REST
if ((e->type() == Element::REST || e->type() == Element::REPEAT_MEASURE)
&& (duration >= rest || e == back())
&& (rest == m->len()))
{
Expand All @@ -339,7 +342,7 @@ bool TrackList::write(int track, Measure* measure) const
}
else {
Fraction d = qMin(rest, duration);
if (e->type() == Element::REST) {
if (e->type() == Element::REST || e->type() == Element::REPEAT_MEASURE) {
segment = m->getSegment(Segment::SegChordRest, m->tick() + pos.ticks());
Rest* r = new Rest(score, TDuration(d));
r->setTrack(track);
Expand Down Expand Up @@ -509,10 +512,19 @@ bool ScoreRange::write(int track, Measure* m) const
if (!dl->write(track + i, m))
return false;
}
return true;
}

//---------------------------------------------------------
// fixup
//---------------------------------------------------------

void ScoreRange::fixup(Measure* m) const
{
Score* score = m->score();
for (Spanner* s : spanner) {
s->setTick(s->tick() + m->tick());
s->setTick2(s->tick2() + m->tick());
s->setTick(s->tick() + first()->tick());
s->setTick2(s->tick2() + first()->tick());
score->undoAddElement(s);
}
for (const Annotation& a : annotations) {
Expand All @@ -522,7 +534,6 @@ bool ScoreRange::write(int track, Measure* m) const
score->undoAddElement(a.e);
}
}
return true;
}

//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/range.h
Expand Up @@ -77,6 +77,7 @@ class ScoreRange {
void read(Segment* first, Segment* last, int startTrack, int endTrack);
bool canWrite(const Fraction&) const;
bool write(int track, Measure*) const;
void fixup(Measure*) const;
Fraction duration() const;
Segment* first() const { return _first; }
Segment* last() const { return _last; }
Expand Down
1 change: 1 addition & 0 deletions libmscore/splitMeasure.cpp
Expand Up @@ -47,6 +47,7 @@ void Score::cmdSplitMeasure(ChordRest* cr)
m1->setLen(Fraction::fromTicks(ticks1));
m2->setLen(Fraction::fromTicks(ticks2));
range.write(0, m1);
range.fixup(m1);

endCmd();
}
Expand Down

0 comments on commit eec88fd

Please sign in to comment.