diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-05-27 16:43:11 -0500 |
---|---|---|
committer | Carl Sorensen <c_sorensen@byu.edu> | 2010-05-28 15:09:09 -0600 |
commit | 7aca33f5805fcf6af6ccc1fa722abbfbb9b26ee6 (patch) | |
tree | 0fc8515098e1e7fad41cb58bfed589ee8470e63b | |
parent | ade906dcd40bfd2ffb37401252a86cbfc58e6661 (diff) |
don't segfault on invalid engraver names
-rw-r--r-- | input/regression/invalid-engraver.ly | 20 | ||||
-rw-r--r-- | lily/translator-group.cc | 12 |
2 files changed, 26 insertions, 6 deletions
diff --git a/input/regression/invalid-engraver.ly b/input/regression/invalid-engraver.ly new file mode 100644 index 0000000000..ecead3955d --- /dev/null +++ b/input/regression/invalid-engraver.ly @@ -0,0 +1,20 @@ +\version "2.12.0" + +\header { + texidoc="Engravers which do not exist are simply ignored" +} + +\layout { \context { + \name ImproVoice + \type "Engraver_group" + \consists "Rhythmic_column_engraver_foo" % "typo" here +} +\context { \Staff + \accepts "ImproVoice" +}} + +\relative c'' { + a4 d8 bes8 \new ImproVoice { c4^"ad lib" c + c4 c^"undress" c_"while playing :)" c } + a1 +}
\ No newline at end of file diff --git a/lily/translator-group.cc b/lily/translator-group.cc index dc2b772428..7d7847743c 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -153,19 +153,17 @@ 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 = true; Translator *type = 0; - Translator *instance = type; if (ly_is_symbol (definition)) { type = get_translator (definition); - instance = type->clone (); + is_scheme = false; } else if (ly_is_pair (definition)) { type = get_translator (ly_symbol2scm ("Scheme_engraver")); - instance = type->clone (); - dynamic_cast<Scheme_engraver*> (instance)->init_from_scheme (definition); } else if (ly_is_procedure (definition)) { @@ -174,14 +172,16 @@ Translator_group::create_child_translator (SCM sev) // definition. SCM def = scm_call_1 (definition, cs); type = get_translator (ly_symbol2scm ("Scheme_engraver")); - instance = type->clone (); - dynamic_cast<Scheme_engraver*> (instance)->init_from_scheme (def); } if (!type) warning (_f ("cannot find: `%s'", ly_symbol2string (scm_car (s)).c_str ())); else { + Translator *instance = type->clone (); + if (is_scheme) + dynamic_cast<Scheme_engraver*> (instance)->init_from_scheme (definition); + SCM str = instance->self_scm (); if (instance->must_be_last ()) |