]> git.donarmstrong.com Git - lilypond.git/commitdiff
Ambitus_engraver: only acknowledge pitched note heads.
authorNeil Puttock <n.puttock@gmail.com>
Sun, 11 Jan 2009 11:12:52 +0000 (11:12 +0000)
committerNeil Puttock <n.puttock@gmail.com>
Sun, 11 Jan 2009 11:12:52 +0000 (11:12 +0000)
This prevents a segfault if the Ambitus_engraver is added to DrumStaff
or DrumVoice.

input/regression/ambitus-percussion-staves.ly [new file with mode: 0644]
lily/ambitus-engraver.cc

diff --git a/input/regression/ambitus-percussion-staves.ly b/input/regression/ambitus-percussion-staves.ly
new file mode 100644 (file)
index 0000000..5901276
--- /dev/null
@@ -0,0 +1,12 @@
+\version "2.12.2"
+
+\header {
+  texidoc = "Adding ambitus to percussion contexts does not cause
+crashes, since the @code{Ambitus_engraver} will only
+acknowledge pitched note heads."
+}
+
+\new DrumStaff \with { \consists "Ambitus_engraver" } <<
+  \new DrumVoice \drummode { \voiceOne cymr8 cymr }
+  \new DrumVoice \drummode { \voiceTwo hhp4 }
+>>
index 3753249d879f9089069a776453cdc2db4e69f577..202e691d21d6515060cad0b0325fecc7af781200 100644 (file)
@@ -28,8 +28,10 @@ class Ambitus_engraver : public Engraver
 {
 public:
   TRANSLATOR_DECLARATIONS (Ambitus_engraver);
+protected:
+  DECLARE_ACKNOWLEDGER (note_head);
+
   void process_music ();
-  void acknowledge_note_head (Grob_info);
   void stop_translation_timestep ();
   virtual void finalize ();
   virtual void derived_mark () const;
@@ -119,9 +121,16 @@ void
 Ambitus_engraver::acknowledge_note_head (Grob_info info)
 {
   Stream_event *nr = info.event_cause ();
+  SCM p = nr->get_property ("pitch");
+  /*
+    If the engraver is added to a percussion context,
+    filter out unpitched note heads.
+  */
+  if (!unsmob_pitch (p))
+    return;
   if (nr && nr->in_event_class ("note-event"))
     {
-      Pitch pitch = *unsmob_pitch (nr->get_property ("pitch"));
+      Pitch pitch = *unsmob_pitch (p);
       Drul_array<bool> expands = pitch_interval_.add_point (pitch);
       if (expands[UP])
        causes_[UP] = nr;