Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #92331: following chord deleted after voice change #2347

Merged
merged 1 commit into from
Jan 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ void Score::cmdAddSpanner(Spanner* spanner, int staffIdx, Segment* startSegment,

//---------------------------------------------------------
// expandVoice
// fills gaps in voice with rests,
// from previous cr (or beginning of measure) to next cr (or end of measure)
//---------------------------------------------------------

void Score::expandVoice(Segment* s, int track)
Expand All @@ -341,6 +343,7 @@ void Score::expandVoice(Segment* s, int track)
return;
}

// find previous segment with cr in this track
Segment* ps;
for (ps = s; ps; ps = ps->prev(Segment::Type::ChordRest)) {
if (ps->element(track))
Expand All @@ -349,24 +352,22 @@ void Score::expandVoice(Segment* s, int track)
if (ps) {
ChordRest* cr = static_cast<ChordRest*>(ps->element(track));
int tick = cr->tick() + cr->actualTicks();
if (tick == s->tick())
return;
if (tick > s->tick()) {
// previous cr extends past current segment
qDebug("expandVoice: cannot insert element here");
return;
}
if (cr->type() == Element::Type::CHORD) {
// since there was nothing in track at original segment,
// and chord at previous segment does not take us up to tick of original segment.
// we have a hole, but it starts *after* this chord
// move ps to start of hole
// don't move ps for holes after rests
// they will be cleaned up when we fill up to s->tick() with rests below
// previous cr ends on or before current segment
// for chords, move ps to just after cr ends
// so we can fill any gap that might exist
// but don't move ps if previous cr is a rest
// this will be combined with any new rests needed to fill up to s->tick() below
ps = ps->measure()->undoGetSegment(Segment::Type::ChordRest, tick);
}
}
//
// fill upto s->tick() with rests
// fill up to s->tick() with rests
//
Measure* m = s->measure();
int stick = ps ? ps->tick() : m->tick();
Expand All @@ -375,7 +376,7 @@ void Score::expandVoice(Segment* s, int track)
setRest(stick, track, Fraction::fromTicks(ticks), false, 0);

//
// fill from s->tick() until next chord/rest
// fill from s->tick() until next chord/rest in measure
//
Segment* ns;
for (ns = s->next(Segment::Type::ChordRest); ns; ns = ns->next(Segment::Type::ChordRest)) {
Expand Down