]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4997/7: Use Preinit for Global_context, protect output definition
authorDavid Kastrup <dak@gnu.org>
Sat, 4 Jun 2016 17:31:31 +0000 (19:31 +0200)
committerDavid Kastrup <dak@gnu.org>
Fri, 18 Nov 2016 20:49:58 +0000 (21:49 +0100)
lily/context.cc
lily/global-context.cc
lily/include/context.hh
lily/include/global-context.hh

index 7de61c5796fd291739c8f8e700a8132f58e1b2a8..a614146058f55273bc2070d0976c356d10d346b7 100644 (file)
@@ -756,6 +756,11 @@ Context::print_smob (SCM port, scm_print_state *) const
   return 1;
 }
 
+void
+Context::derived_mark () const
+{
+}
+
 SCM
 Context::mark_smob () const
 {
@@ -776,6 +781,8 @@ Context::mark_smob () const
   if (events_below_)
     scm_gc_mark (events_below_->self_scm ());
 
+  derived_mark ();
+
   return properties_scm_;
 }
 
index c21deb3b9ba54651c20cf21237d5ba538a249dc2..47e76718db2bd13e6e1c9236bf27df5ab10ef173 100644 (file)
@@ -30,6 +30,12 @@ using namespace std;
 #include "output-def.hh"
 #include "warn.hh"
 
+void
+Global_context::pre_init ()
+{
+  output_def_ = 0;
+}
+
 Global_context::Global_context (Output_def *o)
   : Context ()
 {
@@ -56,6 +62,13 @@ Global_context::Global_context (Output_def *o)
   accepts_list_ = scm_list_1 (default_child_);
 }
 
+void
+Global_context::derived_mark () const
+{
+  if (output_def_)
+    scm_gc_mark (output_def_->self_scm ());
+}
+
 Output_def *
 Global_context::get_output_def () const
 {
index 468f612061707734ee3865faf8937cba06ea92ec..2555bfe2b49e0e26519c2a1eac630a148d5026b3 100644 (file)
@@ -51,6 +51,7 @@ private:
   Stream_event *infant_event_;
 
 protected:
+  virtual void derived_mark () const;
   Context *daddy_context_;
   /* The used Context_def */
   SCM definition_;
index 75b52c95ae01f9fd943e46ed65add4fd4615be99..fd6f1f92c010c578c03286da4f30e8e3b7951234 100644 (file)
 #include "context.hh"
 #include "pqueue.hh"
 
-class Global_context : public Context
+class Global_context : public Preinit<Global_context>, public Context
 {
   PQueue<Moment> extra_mom_pq_;
   Output_def *output_def_;
+  virtual void derived_mark () const;
 
   DECLARE_CLASSNAME (Global_context);
 
   friend class Output_def;
 public:
+  void pre_init ();
   Global_context (Output_def *);
   int get_moments_left () const;
   Moment sneaky_insert_extra_moment (Moment);