+ Grob *r = Tie::head (ties_[j], RIGHT);
+ for (int i = accidentals_.size (); i--;)
+ if (accidentals_[i].head_ == r)
+ {
+ if (Grob *g = accidentals_[i].accidental_)
+ {
+ g->set_property ("tie", ties_[j]->self_scm ());
+ accidentals_[i].tied_ = true;
+ }
+ ties_.del (j);
+ break;
+ }
+ }
+
+ for (int i = accidentals_.size (); i--;)
+ {
+ int barnum = get_bar_number ();
+
+ Music *note = accidentals_[i].melodic_;
+ Context *origin = accidentals_[i].origin_;
+
+ Pitch *pitch = unsmob_pitch (note->get_property ("pitch"));
+ if (!pitch)
+ continue;
+
+ int n = pitch->get_notename ();
+ int o = pitch->get_octave ();
+ int a = pitch->get_alteration ();
+ SCM key = scm_cons (scm_int2num (o), scm_int2num (n));
+
+ while (origin
+ && origin->where_defined (ly_symbol2scm ("localKeySignature")))