Skip to content

Commit

Permalink
fix #59301 Deleting measure with clef change corrupts clef map
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jun 9, 2015
1 parent 55c0c4f commit 0cdde77
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libmscore/staff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,8 @@ void Staff::insertTime(int tick, int len)
m = m->prevMeasure();
Segment* s = m->findSegment(Segment::Type::Clef, tick);
if (s) {
Clef* clef = static_cast<Clef*>(s->element(idx()));
int track = idx() * VOICES;
Clef* clef = static_cast<Clef*>(s->element(track));
if (clef)
setClef(clef);
}
Expand Down
16 changes: 16 additions & 0 deletions libmscore/undo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3053,6 +3053,22 @@ void InsertRemoveMeasures::removeMeasures()
score->fixTicks();
if (fm->type() == Element::Type::MEASURE) {
score->setPlaylistDirty();

// check if there is a clef at the end of last measure
// remove clef from staff cleflist

if (lm->type() == Element::Type::MEASURE) {
Measure* m = static_cast<Measure*>(lm);
Segment* s = m->findSegment(Segment::Type::Clef, tick2);
if (s) {
for (int staffIdx = 0; staffIdx <= score->nstaves(); ++staffIdx) {
Clef* clef = static_cast<Clef*>(s->element(staffIdx * VOICES));
if (clef)
score->staff(staffIdx)->removeClef(clef);
}
}
}

score->insertTime(tick1, -(tick2 - tick1));
score->setLayoutAll(true);
for (Spanner* sp : score->unmanagedSpanners())
Expand Down

0 comments on commit 0cdde77

Please sign in to comment.