]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix header inheritance
authorNicolas Sceaux <nicolas.sceaux@free.fr>
Sat, 30 Aug 2008 16:21:38 +0000 (18:21 +0200)
committerNicolas Sceaux <nicolas.sceaux@free.fr>
Sat, 30 Aug 2008 16:21:38 +0000 (18:21 +0200)
lily/book.cc
lily/include/book.hh
lily/include/paper-book.hh
lily/paper-book-scheme.cc
lily/paper-book.cc

index aa00be1a02117a26af67569090445ae175720920..7dc79686a9dcfa2ea5963d1b0a875b72d5f1a454 100644 (file)
@@ -127,14 +127,11 @@ Book::set_parent (Book *parent)
       paper_->unprotect ();
     }
   paper_->parent_ = parent->paper_;
-
-  if ((header_ == SCM_EOL) && (scm_is_null (parent->bookparts_)))
+  /* If this part is the first child of parent, copy its header */
+  if (ly_is_module (parent->header_) && (scm_is_null (parent->bookparts_)))
     {
-      /* If this is the first part, and it has no header, copy the 
-       * parent header */
       header_ = ly_make_anonymous_module (false);
-      if (ly_is_module (parent->header_))
-        ly_module_copy (header_, parent->header_);
+      ly_module_copy (header_, parent->header_);
     }
 }
 
@@ -143,6 +140,7 @@ Book::add_bookpart ()
 {
   if (scm_is_pair (scores_))
     {
+      warning ("add_bookpart");
       /* If scores have been added to this book, add them to a child 
        * book part */
       Book *part = new Book;
@@ -191,12 +189,12 @@ Book::process (Output_def *default_paper,
 Paper_book *
 Book::process (Output_def *default_paper,
               Output_def *default_layout,
-               Output_def *parent_paper)
+               Paper_book *parent_part)
 {
   Output_def *paper = paper_ ? paper_ : default_paper;
 
   /* If top book, recursively check score errors */
-  if (!parent_paper && error_found ())
+  if (!parent_part && error_found ())
     return 0;
 
   if (!paper)
@@ -206,8 +204,11 @@ Book::process (Output_def *default_paper,
   Real scale = scm_to_double (paper->c_variable ("output-scale"));
   Output_def *scaled_bookdef = scale_output_def (paper, scale);
   paper_book->paper_ = scaled_bookdef;
-  if (parent_paper)
-    paper_book->paper_->parent_ = parent_paper;
+  if (parent_part)
+    {
+      paper_book->parent_ = parent_part;
+      paper_book->paper_->parent_ = parent_part->paper_;
+    }
   paper_book->header_ = header_;
 
   if (scm_is_pair (bookparts_))
@@ -219,7 +220,7 @@ Book::process (Output_def *default_paper,
           if (Book *book = unsmob_book (scm_car (p)))
             {
               Paper_book *paper_book_part = book
-                ->process (paper, default_layout, paper_book->paper_);
+                ->process (paper, default_layout, paper_book);
               if (paper_book_part)
                 paper_book->add_bookpart (paper_book_part->self_scm ());
             }
index d92bcc72a25e346e164c4418f452f3e61a3caf35..1f3af9c50773727714a45ce4c92785c66470d21c 100644 (file)
@@ -40,7 +40,7 @@ public:
                       Output_def *def_layout);
   Paper_book *process (Output_def *default_paper,
                        Output_def *default_layout,
-                       Output_def *parent_paper);
+                       Paper_book *parent_part);
   void set_keys ();
 };
 
index 1aaf6fab0a04e1353b18ee93ca5d2860a28f117f..48988380813d419bc3b93d25812ffe02dee1b6d6 100644 (file)
@@ -32,6 +32,7 @@ public:
   SCM header_0_;
   SCM scores_;
   SCM bookparts_;
+  Paper_book *parent_;
   Output_def *paper_;
 
   Paper_book ();
index 275e3ced535073f083ecb470d4e40882b4d5555f..d9832e4c0e2dd47b0e0cd17aad2aa812a48a03ec 100644 (file)
@@ -20,12 +20,16 @@ LY_DEFINE (ly_paper_book_pages, "ly:paper-book-pages",
 
 LY_DEFINE (ly_paper_book_scopes, "ly:paper-book-scopes",
           1, 0, 0, (SCM book),
-          "Return pages in layout book @var{book}.")
+          "Return scopes in layout book @var{book}.")
 {
   LY_ASSERT_SMOB (Paper_book, book, 1);
   Paper_book *pb = unsmob_paper_book (book);
 
   SCM scopes = SCM_EOL;
+  if (pb->parent_)
+    {
+      scopes = ly_paper_book_scopes (pb->parent_->self_scm ());
+    }
   if (ly_is_module (pb->header_))
     scopes = scm_cons (pb->header_, scopes);
 
index 907ff1bd776f5b14af0668ad112928fb098fd79f..b941c14e1b4ed293cdb9b8e920d5f5c790ff57a4 100644 (file)
@@ -32,6 +32,7 @@ Paper_book::Paper_book ()
   systems_ = SCM_BOOL_F;
 
   paper_ = 0;
+  parent_ = 0;
   smobify_self ();
 }
 
@@ -49,6 +50,8 @@ Paper_book::mark_smob (SCM smob)
   Paper_book *b = (Paper_book *) SCM_CELL_WORD_1 (smob);
   if (b->paper_)
     scm_gc_mark (b->paper_->self_scm ());
+  if (b->parent_)
+    scm_gc_mark (b->parent_->self_scm ());
   scm_gc_mark (b->header_);
   scm_gc_mark (b->header_0_);
   scm_gc_mark (b->pages_);