]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 5116/1: Allow \change to same context type
authorDavid Kastrup <dak@gnu.org>
Thu, 6 Apr 2017 07:50:24 +0000 (09:50 +0200)
committerDavid Kastrup <dak@gnu.org>
Thu, 13 Apr 2017 06:04:30 +0000 (08:04 +0200)
The \change command no longer refuses to change the parent of a
context when the context itself would be of the proper type to
change to.  This allows changing the parent of a context that
could be nested, like StaffGroup in StaffGroup or NullVoice
in Staff (since NullVoice is also aliased to Staff).

lily/change-iterator.cc
lily/context.cc

index 0f8823d484350fdb580998ba2895e2f0227bb7df..f70c2da47fcdd94410c1b1da34640cb403d9fc54 100644 (file)
@@ -68,13 +68,9 @@ Change_iterator::change_to (Music_iterator &it,
     }
   else if (it.get_outlet ()->is_alias (to_type))
     {
-      // No enclosing context was found because the iterator's immediate
-      // context is the kind that was sought.
-      /* We could change the current translator's id, but that would make
-         errors hard to catch.
+      // No enclosing context of the right kind was found
+      // and the iterator's immediate context is the kind that was sought.
 
-         last->translator_id_string () = get_change
-         ()->change_to_id_string (); */
       result = _f ("not changing to same context type: %s", ly_symbol2string (to_type).c_str ());
     }
   else
index 7dce3857cec672243312ec9a6defa0b58fc63cc5..9e99577019660272cbbc5c1bdc66c7e1dcea7030 100644 (file)
@@ -674,11 +674,12 @@ find_context_above (Context *where, SCM type)
 Context *
 find_context_above_by_parent_type (Context *where, SCM parent_type)
 {
-  for (Context *child = 0; where;
-       child = where, where = where->get_parent_context ())
-    if (where->is_alias (parent_type))
-      return child;
-
+  while (Context *parent = where->get_parent_context ())
+    {
+      if (parent->is_alias (parent_type))
+        return where;
+      where = parent;
+    }
   return 0;
 }