From: Neil Puttock Date: Tue, 7 Dec 2010 23:39:05 +0000 (+0000) Subject: Fix #1427. X-Git-Tag: release/2.13.42-1~8 X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=a8d84c480a22f6ec2a20404cf4260e3f1d98866f;p=lilypond.git Fix #1427. The copy constructor for Book assumes the list of objects to clone are scores, which is unsafe since a \book(part) block can also contain markup and page markers. * input/regression (book-identifier-markup.ly): new regtest * lily/book.cc (copy constructor): treat entries in scores_ separately, cloning Score and Page_marker objects * lily/include/page-marker.hh, lily/page-marker.cc: add copy constructor --- diff --git a/input/regression/book-identifier-markup.ly b/input/regression/book-identifier-markup.ly new file mode 100644 index 0000000000..a8521172a1 --- /dev/null +++ b/input/regression/book-identifier-markup.ly @@ -0,0 +1,14 @@ +\version "2.13.42" + +\header { + texidoc = "A @code{\\book} or @code{\\bookpart} identifier can contain +top-level markup and page-markers." +} + +mypart = \bookpart { + \relative c' { c1 } + \label #'marker + \markup { Page \page-ref #'marker "8" "?" } +} + +\bookpart { \mypart } diff --git a/lily/book.cc b/lily/book.cc index efd26d44eb..190f077e02 100644 --- a/lily/book.cc +++ b/lily/book.cc @@ -67,15 +67,21 @@ Book::Book (Book const &s) header_ = ly_make_module (false); if (ly_is_module (s.header_)) ly_module_copy (header_, s.header_); - SCM *t = &scores_; for (SCM p = s.scores_; scm_is_pair (p); p = scm_cdr (p)) { - Score *newscore = unsmob_score (scm_car (p))->clone (); + SCM entry = scm_car (p); - *t = scm_cons (newscore->self_scm (), SCM_EOL); + if (Score *newscore = unsmob_score (entry)) + *t = scm_cons (newscore->clone ()->unprotect (), SCM_EOL); + else if (Page_marker *marker = unsmob_page_marker (entry)) + *t = scm_cons (marker->clone ()->unprotect (), SCM_EOL); + else + { + /* This entry is a markup list */ + *t = scm_cons (entry, SCM_EOL); + } t = SCM_CDRLOC (*t); - newscore->unprotect (); } t = &bookparts_; diff --git a/lily/include/page-marker.hh b/lily/include/page-marker.hh index c8b7e57ddc..6acda2978b 100644 --- a/lily/include/page-marker.hh +++ b/lily/include/page-marker.hh @@ -21,6 +21,7 @@ #define PAGE_MARKER_HH #include "smobs.hh" +#include "virtual-methods.hh" class Page_marker { @@ -32,7 +33,9 @@ class Page_marker public: Page_marker (); - + Page_marker (Page_marker const &); + VIRTUAL_COPY_CONSTRUCTOR (Page_marker, Page_marker); + void set_permission (SCM symbol, SCM permission); void set_label (SCM label); diff --git a/lily/page-marker.cc b/lily/page-marker.cc index fc7b30524d..f1c143a18b 100644 --- a/lily/page-marker.cc +++ b/lily/page-marker.cc @@ -28,6 +28,14 @@ Page_marker::Page_marker () smobify_self (); } +Page_marker::Page_marker (Page_marker const &src) +{ + symbol_ = src.symbol_; + permission_ = src.permission_; + label_ = src.label_; + smobify_self (); +} + Page_marker::~Page_marker () { } @@ -47,10 +55,10 @@ Page_marker::mark_smob (SCM smob) } int -Page_marker::print_smob (SCM smob, SCM port, scm_print_state*) +Page_marker::print_smob (SCM smob, SCM port, scm_print_state *) { Page_marker *pm = (Page_marker *) SCM_CELL_WORD_1 (smob); - (void)pm; + (void) pm; scm_puts ("#", port); return 1; } @@ -85,5 +93,3 @@ Page_marker::set_label (SCM label) { label_ = label; } - -