From 97c36d88858b16986ce00b690da4b9382ffb02bb Mon Sep 17 00:00:00 2001 From: Nicolas Sceaux Date: Sat, 30 Aug 2008 18:21:38 +0200 Subject: [PATCH] Fix header inheritance --- lily/book.cc | 23 ++++++++++++----------- lily/include/book.hh | 2 +- lily/include/paper-book.hh | 1 + lily/paper-book-scheme.cc | 6 +++++- lily/paper-book.cc | 3 +++ 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/lily/book.cc b/lily/book.cc index aa00be1a02..7dc79686a9 100644 --- a/lily/book.cc +++ b/lily/book.cc @@ -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 ()); } diff --git a/lily/include/book.hh b/lily/include/book.hh index d92bcc72a2..1f3af9c507 100644 --- a/lily/include/book.hh +++ b/lily/include/book.hh @@ -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 (); }; diff --git a/lily/include/paper-book.hh b/lily/include/paper-book.hh index 1aaf6fab0a..4898838081 100644 --- a/lily/include/paper-book.hh +++ b/lily/include/paper-book.hh @@ -32,6 +32,7 @@ public: SCM header_0_; SCM scores_; SCM bookparts_; + Paper_book *parent_; Output_def *paper_; Paper_book (); diff --git a/lily/paper-book-scheme.cc b/lily/paper-book-scheme.cc index 275e3ced53..d9832e4c0e 100644 --- a/lily/paper-book-scheme.cc +++ b/lily/paper-book-scheme.cc @@ -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); diff --git a/lily/paper-book.cc b/lily/paper-book.cc index 907ff1bd77..b941c14e1b 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -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_); -- 2.39.5