]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3140: Let find_create_context create Score context for Timing
authorDavid Kastrup <dak@gnu.org>
Sun, 27 Jan 2013 17:33:37 +0000 (18:33 +0100)
committerDavid Kastrup <dak@gnu.org>
Fri, 1 Feb 2013 17:31:49 +0000 (18:31 +0100)
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.

lily/context.cc

index 90b41c155e9572c71fa82befec3e6830a6858fb6..d2c93155a578964e5cf439400fe626236b611ca3 100644 (file)
@@ -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<Global_context *> (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;