Skip to content

Commit

Permalink
Merge pull request #5432 from mattmcclinch/295703-grace-note-slur
Browse files Browse the repository at this point in the history
fix #295703: Slurs to grace notes disappear after inserting bars
  • Loading branch information
dmitrio95 authored Nov 1, 2019
2 parents 3933dac + a37fda3 commit 9c5ee8e
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions libmscore/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4861,8 +4861,8 @@ void Score::undoChangeSpannerElements(Spanner* spanner, Element* startElement, E
{
Element* oldStartElement = spanner->startElement();
Element* oldEndElement = spanner->endElement();
int startDeltaTrack = startElement->track() - oldStartElement->track();
int endDeltaTrack = endElement->track() - oldEndElement->track();
int startDeltaTrack = startElement && oldStartElement ? startElement->track() - oldStartElement->track() : 0;
int endDeltaTrack = endElement && oldEndElement ? endElement->track() - oldEndElement->track() : 0;
// scan all spanners linked to this one
for (ScoreElement* el : spanner->linkList()) {
Spanner* sp = toSpanner(el);
Expand All @@ -4871,24 +4871,28 @@ void Score::undoChangeSpannerElements(Spanner* spanner, Element* startElement, E
// if not the current spanner, but one linked to it, determine its new start and end elements
// as modifications 'parallel' to the modifications of the current spanner's start and end elements
if (sp != spanner) {
// determine the track where to expect the 'parallel' start element
int newTrack = sp->startElement()->track() + startDeltaTrack;
// look in elements linked to new start element for an element with
// same score as linked spanner and appropriate track
for (ScoreElement* ee : startElement->linkList()) {
Element* e = toElement(ee);
if (e->score() == sp->score() && e->track() == newTrack) {
newStartElement = e;
break;
if (startElement) {
// determine the track where to expect the 'parallel' start element
int newTrack = sp->startElement() ? sp->startElement()->track() + startDeltaTrack : 0;
// look in elements linked to new start element for an element with
// same score as linked spanner and appropriate track
for (ScoreElement* ee : startElement->linkList()) {
Element* e = toElement(ee);
if (e->score() == sp->score() && e->track() == newTrack) {
newStartElement = e;
break;
}
}
}
// similarly to determine the 'parallel' end element
newTrack = sp->endElement()->track() + endDeltaTrack;
for (ScoreElement* ee : endElement->linkList()) {
Element* e = toNote(ee);
if (e->score() == sp->score() && e->track() == newTrack) {
newEndElement = e;
break;
if (endElement) {
int newTrack = sp->endElement() ? sp->endElement()->track() + endDeltaTrack : 0;
for (ScoreElement* ee : endElement->linkList()) {
Element* e = toElement(ee);
if (e->score() == sp->score() && e->track() == newTrack) {
newEndElement = e;
break;
}
}
}
}
Expand Down Expand Up @@ -5008,7 +5012,11 @@ void Score::undoInsertTime(const Fraction& tick, const Fraction& len)
// and
// +----spanner--------
// +---add---+
Element* startElement = s->startElement();
Element* endElement = s->endElement();
undoChangeSpannerElements(s, nullptr, nullptr);
s->undoChangeProperty(Pid::SPANNER_TICK, s->tick() + len);
undoChangeSpannerElements(s, startElement, endElement);
}
}
else {
Expand All @@ -5021,7 +5029,11 @@ void Score::undoInsertTime(const Fraction& tick, const Fraction& len)
Fraction t = s->tick() + len;
if (t < Fraction(0,1))
t = Fraction(0,1);
Element* startElement = s->startElement();
Element* endElement = s->endElement();
undoChangeSpannerElements(s, nullptr, nullptr);
s->undoChangeProperty(Pid::SPANNER_TICK, t);
undoChangeSpannerElements(s, startElement, endElement);
}
else if (s->tick() >= tick && s->tick2() <= tick2) {
//
Expand Down

0 comments on commit 9c5ee8e

Please sign in to comment.