From: David Kastrup <dak@gnu.org>
Date: Thu, 12 Sep 2013 17:25:17 +0000 (+0200)
Subject: Issue 3553/1: get_default_interpreter should create contexts with missing context_id
X-Git-Tag: release/2.17.27-1~16
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d756b5523a8d82491f734d79943314c5e6cd35b4;p=lilypond.git

Issue 3553/1: get_default_interpreter should create contexts with missing context_id

At the current point of time, an existing bottom context is returned
even when there is a mismatch in ids.  For example, when writing

\context Voice = "one" <<
  { \voiceOne g' g' g' g' }
  \context Voice = "two" { \voiceTwo c' c' c' c' }
>>

creates two voices, while

\context Bottom = "one" <<
  { \voiceOne g' g' g' g' }
  \context Bottom = "two" { \voiceTwo c' c' c' c' }
>>

only uses a single Voice called "one".  This is arguably wrong.
---

diff --git a/lily/context.cc b/lily/context.cc
index 8d44ca8f85..c72e9eeb25 100644
--- a/lily/context.cc
+++ b/lily/context.cc
@@ -429,6 +429,13 @@ Context::get_default_interpreter (const string &context_id)
       Context *tg = create_context (t, context_id, SCM_EOL);
       return tg->get_default_interpreter (context_id);
     }
+  else if (!context_id.empty () && context_id != id_string ())
+    {
+      if (daddy_context_ && !dynamic_cast<Global_context *> (daddy_context_))
+        return daddy_context_->get_default_interpreter (context_id);
+      warning (_f ("cannot find or create new Bottom = \"%s\"",
+                   context_id.c_str ()));
+    }
   return this;
 }