From ba7dd825738031e7c1f9ec7787594ad78f2442ee Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Sun, 27 Dec 2009 11:18:00 +1100 Subject: [PATCH] Fix 916. Handle the case where a loose line is marked as breakable. Previously, the unbroken version of the last column was included as a loose line, which broke System::broken_col_range. --- .../spacing-loose-grace-linebreak.ly | 1 - lily/include/paper-column.hh | 3 -- lily/paper-column.cc | 6 ++++ lily/spacing-loose-columns.cc | 31 ++++++++++--------- lily/system.cc | 6 ++-- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/input/regression/spacing-loose-grace-linebreak.ly b/input/regression/spacing-loose-grace-linebreak.ly index 8cc2597294..56e7be9ab0 100644 --- a/input/regression/spacing-loose-grace-linebreak.ly +++ b/input/regression/spacing-loose-grace-linebreak.ly @@ -8,7 +8,6 @@ across a line break, it gets attached to the end of line." \new Score \with { \override SpacingSpanner #'strict-grace-spacing = ##t - \override PaperColumn #'used = ##t } << \new Staff << diff --git a/lily/include/paper-column.hh b/lily/include/paper-column.hh index 5e48ff88e5..90a3404416 100644 --- a/lily/include/paper-column.hh +++ b/lily/include/paper-column.hh @@ -29,9 +29,6 @@ class Paper_column : public Item /// if lines are broken then this column is in #line# System *system_; - // ugh: friend declarations. - friend void set_loose_columns (System *which, Column_x_positions const *posns); - friend class System; public: Paper_column (SCM); Paper_column (Paper_column const &); diff --git a/lily/paper-column.cc b/lily/paper-column.cc index 8068846dab..93aa56c041 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -57,6 +57,12 @@ Paper_column::get_rank (Grob const *me) return dynamic_cast (me)->rank_; } +void +Paper_column::set_rank (int rank) +{ + rank_ = rank; +} + System * Paper_column::get_system () const { diff --git a/lily/spacing-loose-columns.cc b/lily/spacing-loose-columns.cc index 4c24470530..d03c3746e4 100644 --- a/lily/spacing-loose-columns.cc +++ b/lily/spacing-loose-columns.cc @@ -37,14 +37,13 @@ set_loose_columns (System *which, Column_x_positions const *posns) if (!loose_col_count) return; + for (int i = 0; i < loose_col_count; i++) + dynamic_cast (posns->loose_cols_[i])->set_system (which); + for (int i = 0; i < loose_col_count; i++) { int divide_over = 1; Item *loose = dynamic_cast (posns->loose_cols_[i]); - Paper_column *col = dynamic_cast (loose); - - if (col->get_system ()) - continue; Item *left = 0; Item *right = 0; @@ -56,8 +55,13 @@ set_loose_columns (System *which, Column_x_positions const *posns) if (!scm_is_pair (between)) break; - Item *le = dynamic_cast (unsmob_grob (scm_car (between))); - Item *re = dynamic_cast (unsmob_grob (scm_cdr (between))); + /* If the line was broken at one of the loose columns, split + the clique at that column. */ + if (!loose->get_system ()) + break; + + Paper_column *le = dynamic_cast (unsmob_grob (scm_car (between))); + Paper_column *re = dynamic_cast (unsmob_grob (scm_cdr (between))); if (! (le && re)) break; @@ -77,13 +81,18 @@ set_loose_columns (System *which, Column_x_positions const *posns) loose = right = re->get_column (); } + if (!right) + { + programming_error ("Can't attach loose column sensibly. Attaching to end of system."); + right = which->get_bound (RIGHT); + } + if (right->get_system ()) ; /* do nothing */ else if (right->find_prebroken_piece (LEFT) && right->find_prebroken_piece (LEFT)->get_system () == which) right = right->find_prebroken_piece (LEFT); else if (Paper_column::get_rank (which->get_bound (RIGHT)) < Paper_column::get_rank (right)) - right = which->get_bound (RIGHT); else { @@ -99,12 +108,6 @@ set_loose_columns (System *which, Column_x_positions const *posns) } } - - if (!right) - { - programming_error ("Can't attach loose column sensibly. Attaching to end of system."); - right = which->get_bound (RIGHT); - } Grob *common = right->common_refpoint (left, X_AXIS); clique.push_back (right); @@ -170,12 +173,10 @@ set_loose_columns (System *which, Column_x_positions const *posns) Real my_offset = right_point - distance_to_next; - clique_col->set_system (which); clique_col->translate_axis (my_offset - clique_col->relative_coordinate (common, X_AXIS), X_AXIS); finished_right_column = clique_col; } - } } diff --git a/lily/system.cc b/lily/system.cc index 61a0edaa8e..5aa3bfe61f 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -248,7 +248,7 @@ System::break_into_pieces (vector const &breaking) for (vsize j = 0; j < c.size (); j++) { c[j]->translate_axis (breaking[i].config_[j], X_AXIS); - dynamic_cast (c[j])->system_ = system; + dynamic_cast (c[j])->set_system (system); /* collect the column labels */ SCM col_labels = c[j]->get_property ("labels"); if (scm_is_pair (col_labels)) @@ -273,7 +273,7 @@ System::add_column (Paper_column *p) ga = unsmob_grob_array (scm_ga); } - p->rank_ = ga->size (); + p->set_rank (ga->size ()); ga->add (p); Axis_group_interface::add_element (this, p); @@ -460,7 +460,7 @@ System::broken_col_range (Item const *left, Item const *right) const && Paper_column::get_rank (cols[i]) < end_rank) { Paper_column *c = dynamic_cast (cols[i]); - if (Paper_column::is_breakable (c) && !c->system_) + if (Paper_column::is_breakable (c) && !c->get_system ()) ret.push_back (c); i++; } -- 2.39.5