]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3797: Music_wrapper_iterator does not follow original context setting of child
authorDavid Kastrup <dak@gnu.org>
Sat, 11 Jan 2014 13:08:55 +0000 (14:08 +0100)
committerDavid Kastrup <dak@gnu.org>
Sat, 15 Feb 2014 18:13:47 +0000 (19:13 +0100)
We do this by making Music_iterator::get_handle and
Music_iterator::set_context virtual and letting Music_wrapper_iterator
redirect them to the child iterator.

\score {
  <<
    { { a4 a b b } a a b b }
    { \absolute { a4 a b b } a a b b }
  >>
}

splits off a new Staff after \absolute { a4 a b b }.

lily/include/music-iterator.hh
lily/include/music-wrapper-iterator.hh
lily/music-iterator.cc
lily/music-wrapper-iterator.cc

index a34e3009037120f66baeeda9104d27a753ffe43a..3fcfa8d58cf8996d640e89e1b9737d0912449f89 100644 (file)
@@ -73,8 +73,8 @@ public:
   Moment music_start_mom () const;
   Music_iterator ();
   void report_event (Music *);
-  Context *get_outlet () const;
-  void set_context (Context *);
+  virtual Context *get_outlet () const;
+  virtual void set_context (Context *);
   static SCM get_static_get_iterator (Music *mus);
   void init_context (Music *, Context *);
   void quit ();
index a306226724f42340d42b2319e1ad02c329f4eb5a..8553b3958a5bed194e9bca7b5b4273194771f70b 100644 (file)
@@ -34,6 +34,8 @@ public:
   Music_wrapper_iterator ();
   DECLARE_CLASSNAME (Music_wrapper_iterator);
 
+  virtual Context *get_outlet () const;
+  virtual void set_context (Context *trans);
   virtual void derived_substitute (Context *f, Context *t);
   virtual void derived_mark () const;
   virtual void construct_children ();
index c076b7ad65867e9e9b3cdb9266ae0748c1dd7586..6ba70eb63d1e1e918add042de670b91eca6ec477 100644 (file)
@@ -207,8 +207,11 @@ Music_iterator::mark_smob (SCM smob)
     Careful with GC, although we intend the following as pointers
     only, we _must_ mark them.
   */
-  if (mus->get_outlet ())
-    scm_gc_mark (mus->get_outlet ()->self_scm ());
+  /* Use handle_ directly as get_outlet is a virtual function and we
+     need to protect the context until Music_iterator::quit is being
+     run. */
+  if (mus->handle_.get_context ())
+    scm_gc_mark (mus->handle_.get_context ()->self_scm ());
   if (mus->music_)
     scm_gc_mark (mus->music_->self_scm ());
 
index e208d135f5c75bf63973866b8815695263f4499c..8f201a65c145e425be9d7c825945263999a99a77 100644 (file)
@@ -79,6 +79,22 @@ Music_wrapper_iterator::pending_moment () const
     return Music_iterator::pending_moment ();
 }
 
+Context *
+Music_wrapper_iterator::get_outlet () const
+{
+  if (child_iter_)
+    return child_iter_->get_outlet ();
+  return Music_iterator::get_outlet ();
+}
+
+void
+Music_wrapper_iterator::set_context (Context *trans)
+{
+  if (child_iter_)
+    child_iter_->set_context (trans);
+  Music_iterator::set_context (trans);
+}
+
 IMPLEMENT_CTOR_CALLBACK (Music_wrapper_iterator);
 
 bool