From 1b3e857198400b544a72f3772d6c72f3f113bf2f Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 27 May 2010 16:43:11 -0500 Subject: [PATCH] Don't segfault on invalid engraver names. Generate the definition for procedure scheme engravers properly. --- input/regression/invalid-engraver.ly | 16 ++++++++++++++++ lily/translator-group.cc | 19 +++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 input/regression/invalid-engraver.ly diff --git a/input/regression/invalid-engraver.ly b/input/regression/invalid-engraver.ly new file mode 100644 index 0000000000..e3a1fa5731 --- /dev/null +++ b/input/regression/invalid-engraver.ly @@ -0,0 +1,16 @@ +\version "2.13.23" + +#(ly:set-option 'warning-as-error #f) + +\header { + texidoc = "Engravers which do not exist produce a warning." +} + +\layout { + \context { + \Voice + \consists "Rhythmic_column_engraver_foo" + } +} + +{ a4 } diff --git a/lily/translator-group.cc b/lily/translator-group.cc index dc2b772428..84a97bf52e 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -153,35 +153,34 @@ Translator_group::create_child_translator (SCM sev) for (SCM s = trans_names; scm_is_pair (s); s = scm_cdr (s)) { SCM definition = scm_car (s); + bool is_scheme = false; Translator *type = 0; - Translator *instance = type; if (ly_is_symbol (definition)) - { - type = get_translator (definition); - instance = type->clone (); - } + type = get_translator (definition); else if (ly_is_pair (definition)) { type = get_translator (ly_symbol2scm ("Scheme_engraver")); - instance = type->clone (); - dynamic_cast (instance)->init_from_scheme (definition); + is_scheme = true; } else if (ly_is_procedure (definition)) { // `definition' is a procedure, which takes the context as // an argument and evaluates to an a-list scheme engraver // definition. - SCM def = scm_call_1 (definition, cs); + definition = scm_call_1 (definition, cs); type = get_translator (ly_symbol2scm ("Scheme_engraver")); - instance = type->clone (); - dynamic_cast (instance)->init_from_scheme (def); + is_scheme = true; } if (!type) warning (_f ("cannot find: `%s'", ly_symbol2string (scm_car (s)).c_str ())); else { + Translator *instance = type->clone (); + if (is_scheme) + dynamic_cast (instance)->init_from_scheme (definition); + SCM str = instance->self_scm (); if (instance->must_be_last ()) -- 2.39.2