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 #93316: slur still lays out to deleted note #2343

Merged
merged 1 commit into from Jan 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions libmscore/barline.cpp
Expand Up @@ -1507,8 +1507,7 @@ QString BarLine::accessibleExtraInfo()
int tick = seg->tick();

auto spanners = score()->spannerMap().findOverlapping(tick, tick);
for (auto i = spanners.begin(); i < spanners.end(); i++) {
::Interval<Spanner*> interval = *i;
for (auto interval : spanners) {
Spanner* s = interval.value;
if (!score()->selectionFilter().canSelect(s)) continue;
if (s->type() == Element::Type::VOLTA) {
Expand Down
4 changes: 2 additions & 2 deletions libmscore/chord.cpp
Expand Up @@ -2843,8 +2843,8 @@ QPointF Chord::layoutArticulation(Articulation* a)
bool botGap = false;
bool topGap = false;

const std::vector< ::Interval<Spanner*> >& si = score()->spannerMap().findOverlapping(tick(), tick());
for (::Interval<Spanner*> is : si) {
auto si = score()->spannerMap().findOverlapping(tick(), tick());
for (auto is : si) {
Spanner* sp = is.value;
if ((sp->type() != Element::Type::SLUR) || (sp->tick() != tick() && sp->tick2() != tick()))
continue;
Expand Down
3 changes: 1 addition & 2 deletions libmscore/chordrest.cpp
Expand Up @@ -1420,8 +1420,7 @@ QString ChordRest::accessibleExtraInfo()

SpannerMap& smap = score()->spannerMap();
auto spanners = smap.findOverlapping(tick(), tick());
for (auto i = spanners.begin(); i < spanners.end(); i++) {
const ::Interval<Spanner*> interval = *i;
for (auto interval : spanners) {
Spanner* s = interval.value;
if (!score()->selectionFilter().canSelect(s)) continue;
if (s->type() == Element::Type::VOLTA || //voltas are added for barlines
Expand Down
6 changes: 4 additions & 2 deletions libmscore/edit.cpp
Expand Up @@ -446,7 +446,8 @@ bool Score::rewriteMeasures(Measure* fm, Measure* lm, const Fraction& ns, int st

int tick1 = m1->tick();
int tick2 = m2->endTick();
for (auto i : s->spannerMap().findContained(tick1, tick2))
auto spanners = s->spannerMap().findContained(tick1, tick2);
for (auto i : spanners)
undo(new RemoveElement(i.value));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWI, this was what I was concerned about when I thought maybe we might be removing from the list we were iterating on, depending on exactly how those loops are evaluated. Probably there was never a problem because either findContained() is re-evaluated on each iteration, or the result of findContained() was stored in a temporary variable and removing from the score might be removed from the spanner map but the temporary variable wouldn't be affected. Still it seemed awkward, so I just made this look like the others, first calling findContained() and then initiating the loop.

Same story with the call in joinMeasures() a little farther down.

s->undoRemoveMeasures(m1, m2);

Expand Down Expand Up @@ -2126,7 +2127,8 @@ void Score::cmdDeleteSelection()
int tick2 = s2 ? s2->tick() : INT_MAX;
int track1 = selection().staffStart() * VOICES;
int track2 = selection().staffEnd() * VOICES;
for (auto i : _spanner.findOverlapping(stick1, stick2 - 1)) {
auto spanners = _spanner.findOverlapping(stick1, stick2 - 1);
for (auto i : spanners) {
Spanner* sp = i.value;
if (sp->type() == Element::Type::VOLTA)
continue;
Expand Down
3 changes: 2 additions & 1 deletion libmscore/joinMeasure.cpp
Expand Up @@ -33,7 +33,8 @@ void Score::cmdJoinMeasure(Measure* m1, Measure* m2)

int tick1 = m1->tick();
int tick2 = m2->endTick();
for (auto i : _spanner.findContained(tick1, tick2))
auto spanners = _spanner.findContained(tick1, tick2);
for (auto i : spanners)
undo(new RemoveElement(i.value));
undoRemoveMeasures(m1, m2);
Measure* m = new Measure(this);
Expand Down
6 changes: 3 additions & 3 deletions libmscore/layout.cpp
Expand Up @@ -1779,7 +1779,7 @@ static bool validMMRestMeasure(Measure* m)

#if 0
auto l = m->score()->spannerMap().findOverlapping(m->tick(), m->endTick());
for (::Interval<Spanner*> isp : l) {
for (auto isp : l) {
Spanner* s = isp.value;
if (s->type() == Element::Type::VOLTA && (s->tick() == m->tick() || s->tick2() == m->endTick()))
return false;
Expand Down Expand Up @@ -1809,7 +1809,7 @@ static bool breakMultiMeasureRest(Measure* m)
if (m->breakMultiMeasureRest())
return true;
auto sl = m->score()->spannerMap().findOverlapping(m->tick(), m->endTick());
foreach (auto i, sl) {
for (auto i : sl) {
Spanner* s = i.value;
if (s->type() == Element::Type::VOLTA && (s->tick() == m->tick() || s->tick2() == m->tick()))
return true;
Expand Down Expand Up @@ -1841,7 +1841,7 @@ static bool breakMultiMeasureRest(Measure* m)

// break for end of volta
auto l = m->score()->spannerMap().findOverlapping(m->tick(), m->endTick());
for (::Interval<Spanner*> isp : l) {
for (auto isp : l) {
Spanner* s = isp.value;
if (s->type() == Element::Type::VOLTA && (s->tick2() == m->endTick()))
return false;
Expand Down
3 changes: 2 additions & 1 deletion libmscore/rendermidi.cpp
Expand Up @@ -1300,7 +1300,8 @@ void renderGlissando(NoteEventList* events, Note *notestart)
//---------------------------------------------------------

Trill* findFirstTrill(Chord *chord) {
for (auto i : chord->score()->spannerMap().findOverlapping(1+chord->tick(), chord->tick() + chord->actualTicks() - 1)) {
auto spanners = chord->score()->spannerMap().findOverlapping(1+chord->tick(), chord->tick() + chord->actualTicks() - 1);
for (auto i : spanners) {
if (i.value->type() != Element::Type::TRILL)
continue;
if (i.value->track() != chord->track())
Expand Down
2 changes: 1 addition & 1 deletion libmscore/score.cpp
Expand Up @@ -2477,7 +2477,6 @@ void Score::splitStaff(int staffIdx, int splitPoint)
undoRemoveElement(note);
Chord* chord = note->chord();
if (chord->notes().isEmpty()) {
undoRemoveElement(chord);
for (auto sp : spanner()) {
Slur* slur = static_cast<Slur*>(sp.second);
if (slur->type() != Element::Type::SLUR)
Expand All @@ -2497,6 +2496,7 @@ void Score::splitStaff(int staffIdx, int splitPoint)
}
}
}
undoRemoveElement(chord);
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions libmscore/segment.cpp
Expand Up @@ -565,6 +565,16 @@ void Segment::remove(Element* el)
_elist[track] = 0;
int staffIdx = el->staffIdx();
measure()->checkMultiVoices(staffIdx);
// spanners with this cr as start or end element will need relayout
SpannerMap& smap = score()->spannerMap();
auto spanners = smap.findOverlapping(tick(), tick());
for (auto interval : spanners) {
Spanner* s = interval.value;
if (s->startElement() == el)
s->setStartElement(nullptr);
if (s->endElement() == el)
s->setEndElement(nullptr);
}
}
break;

Expand Down Expand Up @@ -1226,9 +1236,8 @@ QString Segment::accessibleExtraInfo()
QString startSpanners = "";
QString endSpanners = "";

std::vector< ::Interval<Spanner*> > spanners = score()->spannerMap().findOverlapping(this->tick(), this->tick());
for (std::vector< ::Interval<Spanner*> >::iterator i = spanners.begin(); i < spanners.end(); i++) {
::Interval<Spanner*> interval = *i;
auto spanners = score()->spannerMap().findOverlapping(this->tick(), this->tick());
for (auto interval : spanners) {
Spanner* s = interval.value;
if (!score()->selectionFilter().canSelect(s)) continue;
if (this->segmentType() == Segment::Type::EndBarLine ||
Expand Down
3 changes: 2 additions & 1 deletion mscore/exportxml.cpp
Expand Up @@ -1368,7 +1368,8 @@ static Volta* findVolta(Measure* m, bool left)
{
int stick = m->tick();
int etick = m->tick() + m->ticks();
for (auto i : m->score()->spannerMap().findOverlapping(stick, etick)) {
auto spanners = m->score()->spannerMap().findOverlapping(stick, etick);
for (auto i : spanners) {
Spanner* el = i.value;
if (el->type() != Element::Type::VOLTA)
continue;
Expand Down