From: David Kastrup Date: Sun, 27 Jan 2013 17:33:37 +0000 (+0100) Subject: Issue 3140: Let find_create_context create Score context for Timing X-Git-Tag: release/2.17.12-1~15 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0392d585b07e3f42cd6a30637cdfe7e2d487c4ab;p=lilypond.git Issue 3140: Let find_create_context create Score context for Timing More exactly: if find_create_context finds that no score context exists yet, but creating one would make it find an alias of it, it does so. This is in order to let \set Timing.xxx = yyy work even in the rare case that the Score context with its hardwired Timing alias does not yet exist. --- diff --git a/lily/context.cc b/lily/context.cc index 90b41c155e..d2c93155a5 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -160,8 +160,29 @@ Context::find_create_context (SCM n, string id, SCM operations) Don't create multiple score contexts. */ Global_context *gthis = dynamic_cast (this); - if (gthis && gthis->get_score_context ()) - return gthis->get_score_context ()->find_create_context (n, id, operations); + if (gthis) + { + if (gthis->get_score_context ()) + return gthis->get_score_context ()->find_create_context (n, id, operations); + + // Special case: If we use \set Timing.xxx = whatever before + // Score is established, the alias of Score to Timing will not + // be taken into account. We check for this particular case + // here. Aliases apart from Score-level ones don't warrant + // context creation as they could create unwanted contexts, like + // RhythmicVoice instead of Voice. Creating a Score context, + // however, can't really do anything wrong. + + SCM score_name = default_child_context_name (); + SCM score_def = find_context_def (get_output_def (), score_name); + + if (Context_def *cd = unsmob_context_def (score_def)) + { + if (cd->is_alias (n)) + return create_context (cd, id, operations); + } + } + if (Context *existing = find_context_below (this, n, id)) return existing;