@@ -5900,69 +5900,71 @@ void Score::connectTies(bool silent)
5900
5900
return ;
5901
5901
}
5902
5902
5903
- SegmentType st = SegmentType::ChordRest;
5904
- for (Segment* s = m->first (st); s; s = s->next1 (st)) {
5905
- for (track_idx_t i = 0 ; i < tracks; ++i) {
5906
- EngravingItem* e = s->element (i);
5907
- if (e == 0 || !e->isChord ()) {
5903
+ auto connectTiesForChord = [silent](Chord* c, Segment* s, track_idx_t track) -> void {
5904
+ for (Note* n : c->notes ()) {
5905
+ if (n->laissezVib ()) {
5908
5906
continue ;
5909
5907
}
5910
- Chord* c = toChord (e);
5911
- for (Note* n : c->notes ()) {
5912
- if (n->laissezVib ()) {
5913
- continue ;
5914
- }
5915
- // connect a tie without end note
5916
- Tie* tie = n->tieFor ();
5917
- if (tie) {
5918
- tie->updatePossibleJumpPoints ();
5919
- }
5920
- if (tie && !tie->isPartialTie () && !tie->endNote ()) {
5921
- Note* nnote;
5922
- if (m_mscVersion <= 114 ) {
5923
- nnote = searchTieNote114 (n);
5924
- } else {
5925
- nnote = searchTieNote (n);
5926
- }
5927
- if (nnote == 0 ) {
5928
- if (!silent) {
5929
- LOGD (" next note at %d track %zu for tie not found (version %d)" , s->tick ().ticks (), i, m_mscVersion);
5930
- delete tie;
5931
- n->setTieFor (0 );
5932
- }
5933
- } else {
5934
- tie->setEndNote (nnote);
5935
- nnote->setTieBack (tie);
5936
- }
5937
- }
5938
- // connect a glissando without initial note (old glissando format)
5939
- for (Spanner* spanner : n->spannerBack ()) {
5940
- if (spanner->isGlissando () && !spanner->startElement ()) {
5941
- Note* initialNote = Glissando::guessInitialNote (n->chord ());
5942
- n->removeSpannerBack (spanner);
5943
- if (initialNote) {
5944
- spanner->setStartElement (initialNote);
5945
- spanner->setEndElement (n);
5946
- spanner->setTick (initialNote->chord ()->tick ());
5947
- spanner->setTick2 (n->chord ()->tick ());
5948
- spanner->setTrack (n->track ());
5949
- spanner->setTrack2 (n->track ());
5950
- spanner->setParent (initialNote);
5951
- initialNote->add (spanner);
5952
- } else {
5953
- delete spanner;
5954
- }
5908
+ // connect a tie without end note
5909
+ Tie* tie = n->tieFor ();
5910
+ if (tie) {
5911
+ tie->updatePossibleJumpPoints ();
5912
+ }
5913
+ if (tie && !tie->isPartialTie () && !tie->endNote ()) {
5914
+ Note* nnote;
5915
+ nnote = searchTieNote (n);
5916
+ if (nnote == 0 ) {
5917
+ if (!silent) {
5918
+ LOGD (" next note at %d track %zu for tie not found" , s->tick ().ticks (), track);
5919
+ delete tie;
5920
+ n->setTieFor (0 );
5955
5921
}
5922
+ } else {
5923
+ tie->setEndNote (nnote);
5924
+ nnote->setTieBack (tie);
5956
5925
}
5957
- // spanner with no end element can happen during copy/paste
5958
- for (Spanner* spanner : n->spannerFor ()) {
5959
- if (spanner->endElement () == nullptr ) {
5960
- n->removeSpannerFor (spanner);
5926
+ }
5927
+ // connect a glissando without initial note (old glissando format)
5928
+ for (Spanner* spanner : n->spannerBack ()) {
5929
+ if (spanner->isGlissando () && !spanner->startElement ()) {
5930
+ Note* initialNote = Glissando::guessInitialNote (n->chord ());
5931
+ n->removeSpannerBack (spanner);
5932
+ if (initialNote) {
5933
+ spanner->setStartElement (initialNote);
5934
+ spanner->setEndElement (n);
5935
+ spanner->setTick (initialNote->chord ()->tick ());
5936
+ spanner->setTick2 (n->chord ()->tick ());
5937
+ spanner->setTrack (n->track ());
5938
+ spanner->setTrack2 (n->track ());
5939
+ spanner->setParent (initialNote);
5940
+ initialNote->add (spanner);
5941
+ } else {
5961
5942
delete spanner;
5962
5943
}
5963
5944
}
5964
5945
}
5946
+ // spanner with no end element can happen during copy/paste
5947
+ for (Spanner* spanner : n->spannerFor ()) {
5948
+ if (spanner->endElement () == nullptr ) {
5949
+ n->removeSpannerFor (spanner);
5950
+ delete spanner;
5951
+ }
5952
+ }
5953
+ }
5954
+ };
5955
+
5956
+ SegmentType st = SegmentType::ChordRest;
5957
+ for (Segment* s = m->first (st); s; s = s->next1 (st)) {
5958
+ for (track_idx_t track = 0 ; track < tracks; ++track) {
5959
+ EngravingItem* e = s->element (track);
5960
+ if (e == 0 || !e->isChord ()) {
5961
+ continue ;
5962
+ }
5963
+ Chord* c = toChord (e);
5964
+ connectTiesForChord (c, s, track);
5965
5965
for (Chord* gc : c->graceNotes ()) {
5966
+ connectTiesForChord (gc, s, track);
5967
+
5966
5968
for (Note* n : gc->notes ()) {
5967
5969
// spanner with no end element apparently happens when reading some 206 files
5968
5970
// (and possibly in other situations too)
0 commit comments