- continue;
-
- if (ly_is_equal (right_ev->get_property ("pitch"),
- left_ev->get_property ("pitch")))
- {
- Grob *p = new Spanner (heads_to_tie_[i].tie_definition_);
-
- SCM cause = heads_to_tie_[i].tie_event_
- ? heads_to_tie_[i].tie_event_->self_scm ()
- : heads_to_tie_[i].tie_stream_event_->self_scm ();
-
- announce_grob (p, cause);
- Tie::set_head (p, LEFT, th);
- Tie::set_head (p, RIGHT, h);
-
-
- if (is_direction (unsmob_stream_event (cause)->get_property ("direction")))
- {
- Direction d = to_dir (unsmob_stream_event (cause)->get_property ("direction"));
- p->set_property ("direction", scm_from_int (d));
- }
-
- ties_.push_back (p);
- heads_to_tie_.erase (heads_to_tie_.begin () + i);
- }
+ continue;
+
+ /*
+ Make a tie only if pitches are equal or if event end was not generated by
+ Completion_heads_engraver.
+ */
+ SCM p1 = left_ev->get_property ("pitch");
+ SCM p2 = right_ev->get_property ("pitch");
+ if ((enharmonic
+ ? (unsmob<Pitch> (p1) && unsmob<Pitch> (p2) &&
+ unsmob<Pitch> (p1)->tone_pitch () == unsmob<Pitch> (p2)->tone_pitch ())
+ : ly_is_equal (p1, p2))
+ && (!Tie_engraver::has_autosplit_end (left_ev)))
+ {
+ Spanner *p = heads_to_tie_[i].tie_;
+ Moment end = heads_to_tie_[i].end_moment_;
+
+ Stream_event *cause = heads_to_tie_[i].tie_event_
+ ? heads_to_tie_[i].tie_event_
+ : heads_to_tie_[i].tie_stream_event_;
+
+ announce_end_grob (p, cause->self_scm ());
+
+ Tie::set_head (p, LEFT, th);
+ Tie::set_head (p, RIGHT, h);
+
+ if (is_direction (cause->get_property ("direction")))
+ {
+ Direction d = to_dir (cause->get_property ("direction"));
+ p->set_property ("direction", scm_from_int (d));
+ }
+
+ ties_.push_back (p);
+ heads_to_tie_.erase (heads_to_tie_.begin () + i);
+
+ found = true;
+ /*
+ Prevent all other tied notes ending at the same moment (assume
+ implicitly the notes have also started at the same moment!)
+ from triggering an "unterminated tie" warning. Needed e.g. for
+ <c e g>~ g
+ */
+ for (vsize j = heads_to_tie_.size (); j--;)
+ {
+ if (heads_to_tie_[j].end_moment_ == end)
+ heads_to_tie_[j].tie_from_chord_created = true;
+ }
+ break;
+ }