]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 916.
authorJoe Neeman <joeneeman@gmail.com>
Sun, 27 Dec 2009 00:18:00 +0000 (11:18 +1100)
committerJoe Neeman <joeneeman@gmail.com>
Sun, 27 Dec 2009 07:31:41 +0000 (18:31 +1100)
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.

input/regression/spacing-loose-grace-linebreak.ly
lily/include/paper-column.hh
lily/paper-column.cc
lily/spacing-loose-columns.cc
lily/system.cc

index 8cc2597294cd392a5835cc98cc02db972d2dea6c..56e7be9ab003b0412e46681c8d42e95dc0fe5bd7 100644 (file)
@@ -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 <<
index 5e48ff88e544536b944a77dff5cd396f5e159952..90a3404416dbc71afbb7ffc77ac85647526c29e6 100644 (file)
@@ -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 &);
index 8068846dab7661e56198ba8b9265114065b5681c..93aa56c0419c7fd2e604da77fc15c9f0219cfb9b 100644 (file)
@@ -57,6 +57,12 @@ Paper_column::get_rank (Grob const *me)
   return dynamic_cast<Paper_column const *> (me)->rank_;
 }
 
+void
+Paper_column::set_rank (int rank)
+{
+  rank_ = rank;
+}
+
 System *
 Paper_column::get_system () const
 {
index 4c2447053032974dc468b3683a40ab8248031a75..d03c3746e49fc4c7a0d3693e46671d0b42cd592e 100644 (file)
@@ -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<Paper_column *> (posns->loose_cols_[i])->set_system (which);
+
   for (int i = 0; i < loose_col_count; i++)
     {
       int divide_over = 1;
       Item *loose = dynamic_cast<Item *> (posns->loose_cols_[i]);
-      Paper_column *col = dynamic_cast<Paper_column *> (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<Item *> (unsmob_grob (scm_car (between)));
-         Item *re = dynamic_cast<Item *> (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<Paper_column *> (unsmob_grob (scm_car (between)));
+         Paper_column *re = dynamic_cast<Paper_column *> (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;
        }
     }
 }
 
index 61a0edaa8eef1d6fc5be109545fa1c87edbc8edf..5aa3bfe61fe108b9ef4b4eac46cbe90c1ed427ea 100644 (file)
@@ -248,7 +248,7 @@ System::break_into_pieces (vector<Column_x_positions> const &breaking)
       for (vsize j = 0; j < c.size (); j++)
        {
          c[j]->translate_axis (breaking[i].config_[j], X_AXIS);
-         dynamic_cast<Paper_column *> (c[j])->system_ = system;
+         dynamic_cast<Paper_column *> (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<Paper_column *> (cols[i]);
-      if (Paper_column::is_breakable (c) && !c->system_)
+      if (Paper_column::is_breakable (c) && !c->get_system ())
        ret.push_back (c);
       i++;
     }