]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/translator-group.cc
don't segfault on invalid engraver names
[lilypond.git] / lily / translator-group.cc
index 44b4e1fe0a1742dbb1e2fb34eeada2589004c2cd..7d7847743c59e3886036e4feed9d938196ede2b0 100644 (file)
@@ -153,25 +153,35 @@ 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))
+       {
+         // `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);
+         type = get_translator (ly_symbol2scm ("Scheme_engraver"));
        }
         
       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 ())