+ for (vsize j = slurs_.size (); j--;)
+ {
+ Grob *slur = slurs_[j];
+ Direction updown = to_dir (ev->get_property ("direction"));
+
+ // Check if we already have a slur with the same spanner-id.
+ if (ly_is_equal (id, slur->get_property ("spanner-id")))
+ {
+ if (j < old_slurs)
+ {
+ // We already have an old slur, so give a warning
+ // and completely ignore the new slur.
+ ev->origin ()->warning (_f ("already have %s", object_name ()));
+ if (event_idx)
+ start_events_.erase (start_events_.begin () + (*event_idx));
+ return false;
+ }
+
+ // If this slur event has no direction, it will not
+ // contribute anything new to the existing slur(s), so
+ // we can ignore it.
+
+ if (!updown)
+ return false;
+
+ Stream_event *c = unsmob<Stream_event> (slur->get_property ("cause"));
+
+ if (!c)
+ {
+ slur->programming_error (_f ("%s without a cause", object_name ()));
+ return true;
+ }
+
+ Direction slur_dir = to_dir (c->get_property ("direction"));
+
+ // If the existing slur does not have a direction yet,
+ // we'd rather take the new one.
+
+ if (!slur_dir)
+ {
+ slur->suicide ();
+ slurs_.erase (slurs_.begin () + j);
+ return true;
+ }
+
+ // If the existing slur has the same direction as ours, drop ours
+
+ if (slur_dir == updown)
+ return false;
+ }
+ }
+ return true;
+}
+
+bool
+Slur_engraver::try_to_end (Event_info evi)
+{
+ SCM id = evi.slur_->get_property ("spanner-id");
+
+ // Find the slurs that are ended with this event (by checking the spanner-id)
+ bool ended = false;
+ for (vsize j = slurs_.size (); j--;)
+ {
+ if (ly_is_equal (id, slurs_[j]->get_property ("spanner-id")))
+ {
+ ended = true;
+ end_slurs_.push_back (slurs_[j]);
+ if (evi.note_)
+ note_slurs_[STOP].insert
+ (Note_slurs::value_type
+ (evi.note_, dynamic_cast <Spanner *> (slurs_[j])));
+ slurs_.erase (slurs_.begin () + j);
+ }
+ }
+ return ended;