]> 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, 18 Jan 2014 14:36:58 +0000 (15:36 +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 c2613bdbdfeac98890537bab6df17b4359a6bc8c..9bb2637404d0de13bb2d5702b1b13a46a650a3ad 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 967f1abd0c171d2ff89cb7f0253efe7e6f7d3b4f..efb460d8c11b27e0c4d6941998ba8936f78efce6 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 c875b060a565b1db6cf9bd8d15ac43a17acee364..f6367db129620230d1d56be339a194a0a9f163d0 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 93139715bd4ecd5daac36347e6ed300051f60835..d46415869c658c39d88b944c28fe94f72fbc7fa0 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