From: Han-Wen Nienhuys Date: Mon, 22 Mar 2004 22:33:57 +0000 (+0000) Subject: (ordered_elements): we cannot X-Git-Tag: release/2.1.34~10 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=10c51c532f5fbe5ca438e311bc10f03d2e750325;p=lilypond.git (ordered_elements): we cannot modify the #'elements property, so return reordered array. --- diff --git a/ChangeLog b/ChangeLog index d1cc15defb..eccd595f38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-03-22 Han-Wen Nienhuys + + * lily/break-align-interface.cc (ordered_elements): we cannot + modify the #'elements property, so return reordered array. + 2004-03-23 Heikki Junes * buildscripts/lilypond.words.py: remove. diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 40ea7ca721..1f628a458c 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -62,7 +62,7 @@ Axis_group_interface::group_extent_callback (SCM element_smob, SCM scm_axis) Grob * common = common_refpoint_of_list (elts, me, a); Real my_coord = me->relative_coordinate (common, a); - Interval r (relative_group_extent (a, common,elts)); + Interval r (relative_group_extent (a, common, elts)); return ly_interval2scm (r - my_coord); } diff --git a/lily/box.cc b/lily/box.cc index a61a8abf08..5ec4a9f039 100644 --- a/lily/box.cc +++ b/lily/box.cc @@ -80,5 +80,4 @@ Box::widen (Real x, Real y) { interval_a_[X_AXIS].widen (x); interval_a_[Y_AXIS].widen (y); - } diff --git a/lily/break-align-interface.cc b/lily/break-align-interface.cc index aadb89a998..3e5f9d38b5 100644 --- a/lily/break-align-interface.cc +++ b/lily/break-align-interface.cc @@ -63,49 +63,46 @@ Break_align_interface::self_align_callback (SCM element_smob, SCM axis) } -void -Break_align_interface::order_elements (Grob *grob) +/* + This is tricky: we cannot modify 'elements, since callers are + iterating the same list. Reordering the list in-place, or resetting + 'elements will skip elements in the loops of callers. + + So we return the correct order as an array. + */ +Link_array +Break_align_interface::ordered_elements (Grob *grob) { Item *me = dynamic_cast (grob); SCM elts = me->get_property ("elements"); SCM order_vec = me->get_property ("break-align-orders"); if (!gh_vector_p (order_vec) || gh_vector_length (order_vec) < 3) - return ; - + return Pointer_group_interface__extract_grobs (me, (Grob*)0, + "elements"); SCM order = scm_vector_ref (order_vec, gh_int2scm (me->break_status_dir() + 1)); + /* - Copy in order specified in BREAK-ALIGN-ORDER. We use - Pointer_group_interface__extract_grobs (which reverses the list) - down the line, so it's ok to prepend onto newlist. - */ - SCM new_list = SCM_EOL; + Copy in order specified in BREAK-ALIGN-ORDER. + */ + Link_array new_elts; for (; gh_pair_p (order); order = ly_cdr (order)) { SCM sym = gh_car (order); - - SCM *tail = &elts; - for (; gh_pair_p (*tail); tail = SCM_CDRLOC(*tail)) + + for (SCM s =elts; gh_pair_p (s); s = gh_cdr (s)) { - Grob * g = unsmob_grob (gh_car (*tail)); - if (sym == g->get_property ("break-align-symbol")) + Grob *g = unsmob_grob (gh_car (s)); + if (g && sym == g->get_property ("break-align-symbol")) { - SCM new_pair = *tail; - *tail = gh_cdr (*tail); - if (gh_pair_p (*tail)) - tail = SCM_CDRLOC(*tail); - - gh_set_cdr_x (new_pair, new_list); - new_list = new_pair; - break; + new_elts.push (g); + elts = scm_delq (g->self_scm (), elts); } } } - - new_list = scm_reverse_x (elts, new_list); - me->set_property ("elements", new_list); + return new_elts; } void @@ -119,11 +116,8 @@ Break_align_interface::do_alignment (Grob *grob) { Item * me = dynamic_cast (grob); - order_elements (me); - Link_array elems - = Pointer_group_interface__extract_grobs (me, (Grob*)0, - "elements"); + Link_array elems = ordered_elements (me); Array extents; int last_nonempty = -1; diff --git a/lily/include/break-align-interface.hh b/lily/include/break-align-interface.hh index 123fca1315..a79e7e0a39 100644 --- a/lily/include/break-align-interface.hh +++ b/lily/include/break-align-interface.hh @@ -16,8 +16,7 @@ class Break_align_interface { public: static void do_alignment (Grob*); - static void new_do_alignment (Grob*); - static void order_elements (Grob *me); + static Link_array ordered_elements (Grob *me); static bool has_interface (Grob*); static void add_element (Grob*me, Grob*add); DECLARE_SCHEME_CALLBACK (alignment_callback, (SCM element, SCM axis)); diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc index 9436069dd8..51101be0e2 100644 --- a/lily/multi-measure-rest.cc +++ b/lily/multi-measure-rest.cc @@ -144,7 +144,7 @@ Multi_measure_rest::symbol_stencil (Grob *me, Real space) SCM sml = me->get_property ("use-breve-rest"); if (measures == 1) { - if (sml == SCM_BOOL_T) + if (to_boolean (sml)) { Stencil s = musfont->find_by_name (Rest::glyph_name (me, -1, "")); @@ -317,13 +317,16 @@ Multi_measure_rest::set_spacing_rods (SCM smob) Item * lb = l->find_prebroken_piece (RIGHT); Item * rb = r->find_prebroken_piece (LEFT); - Item* combinations[4][2]={{l,r}, {lb,r}, {l,rb},{lb,rb}}; + Item* combinations[4][2] = {{l,r}, + {lb,r}, + {l,rb}, + {lb,rb}}; Real sym_width = symbol_stencil (me, 0.0).extent (X_AXIS).length (); for (int i=0; i < 4; i++) { - Item * l = combinations[i][0]; + Item *l = combinations[i][0]; Item *r = combinations[i][1]; if (!l || !r) diff --git a/lily/property-iterator.cc b/lily/property-iterator.cc index def29de765..d3007f8433 100644 --- a/lily/property-iterator.cc +++ b/lily/property-iterator.cc @@ -106,8 +106,7 @@ Push_property_iterator::process (Moment m) SCM val = get_music ()->get_property ("grob-value"); if (to_boolean (get_music ()->get_property ("pop-first")) - && !to_boolean (get_music ()->get_property ("once")) - ) + && !to_boolean (get_music ()->get_property ("once"))) execute_pushpop_property (get_outlet (), sym, eprop, SCM_UNDEFINED); execute_pushpop_property (get_outlet (), sym, eprop, val); diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index 80b446534b..a2665fad29 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -163,7 +163,6 @@ Separating_line_group_engraver::acknowledge_grob (Grob_info i) } else if (last_spacings_.staff_spacing_) { - last_spacings_.staff_spacing_->set_property ("right-items", gh_cons (break_item_->self_scm (), SCM_EOL)); } diff --git a/lily/translator-property.cc b/lily/translator-property.cc index 3b793713d1..4d7a8016d3 100644 --- a/lily/translator-property.cc +++ b/lily/translator-property.cc @@ -44,6 +44,7 @@ execute_pushpop_property (Context * trg, */ if (!where) return ; + if (where != trg) { SCM base = updated_grob_properties (trg, prop);