]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 2951: Allow music of nominally zero duration to be typeset.
authorDavid Kastrup <dak@gnu.org>
Tue, 6 Nov 2012 16:43:45 +0000 (17:43 +0100)
committerDavid Kastrup <dak@gnu.org>
Mon, 19 Nov 2012 07:16:41 +0000 (08:16 +0100)
This is important for things like incipits without notes or other
material that produces output without spending time.  In particular,
this is interesting for \score in markup which more often than not
only contains few notational elements and where attempts to just get
basic key/clef/timesignature drawings are sometimes failing in
frustrating manners.

lily/constrained-breaking.cc
lily/global-context-scheme.cc
lily/optimal-page-breaking.cc
lily/page-spacing.cc
lily/simple-spacer.cc

index c8b7fc1d748bc06ae2074d33d436d77ab1bdd2e5..ee8b28906c5f6d476e82b49cb3afeba92974b833 100644 (file)
@@ -202,8 +202,10 @@ Constrained_breaking::solve (vsize start, vsize end, vsize sys_count)
         }
     }
   /* if we get to here, just put everything on one line */
-  warning (_ ("cannot find line breaking that satisfies constraints"));
-  ret.push_back (space_line (0, end_brk));
+  if (sys_count > 0) {
+    warning (_ ("cannot find line breaking that satisfies constraints"));
+    ret.push_back (space_line (0, end_brk));
+  }
   return ret;
 }
 
@@ -291,9 +293,11 @@ Constrained_breaking::line_details (vsize start, vsize end, vsize sys_count)
     }
 
   /* if we get to here, just put everything on one line */
-  Line_details details;
-  fill_line_details (&details, 0, end_brk);
-  ret.push_back (details);
+  if (sys_count > 0) {
+    Line_details details;
+    fill_line_details (&details, 0, end_brk);
+    ret.push_back (details);
+  }
   return ret;
 }
 
index 1267793cf3564b3e3198aeffe3b235a7ef3e2528..86ee2b05b963132936020f212fa5ef09a613b5c6 100644 (file)
@@ -90,8 +90,7 @@ LY_DEFINE (ly_interpret_music_expression, "ly:interpret-music-expression",
   LY_ASSERT_TYPE (unsmob_global_context, ctx, 2);
 
   Music *music = unsmob_music (mus);
-  if (!music
-      || !music->get_length ().to_bool ())
+  if (!music)
     {
       warning (_ ("no music found in score"));
       return SCM_BOOL_F;
index 2b0910f8873600feebf136424c8ffa823d0f93d6..3bddcad4ba66815806fa1e691a2c2f229e1fc8f9 100644 (file)
@@ -64,12 +64,19 @@ Optimal_page_breaking::solve ()
       best = space_systems_on_best_pages (0, first_page_num);
 
       page_count = best.systems_per_page_.size ();
-      min_sys_count = ideal_sys_count - best.systems_per_page_.back ();
+      if (page_count == 0)
+        {
+          min_sys_count = 0;
+        }
+      else
+        {
+          min_sys_count = ideal_sys_count - best.systems_per_page_.back ();
 
-      if (page_count > 1 && best.systems_per_page_[page_count - 2] > 1)
-        min_sys_count -= best.systems_per_page_[page_count - 2];
+          if (page_count > 1 && best.systems_per_page_[page_count - 2] > 1)
+            min_sys_count -= best.systems_per_page_[page_count - 2];
 
-      min_sys_count = max (min_sys_count, (vsize)1);
+          min_sys_count = max (min_sys_count, (vsize)1);
+        }
     }
   else
     {
@@ -103,7 +110,7 @@ Optimal_page_breaking::solve ()
 
   if (page_count == 1)
     message (_ ("Fitting music on 1 page..."));
-  else if (scm_is_integer (forced_page_count))
+  else if (scm_is_integer (forced_page_count) || page_count == 0)
     message (_f ("Fitting music on %d pages...", (int)page_count));
   else
     message (_f ("Fitting music on %d or %d pages...", (int)page_count - 1, (int)page_count));
index 9434fb910aab7705be46630374f25a5bc4e51cd6..c2988d8502e37785a54ebf658932710aa310c6bb 100644 (file)
@@ -155,6 +155,9 @@ Page_spacer::solve ()
     }
 
   Page_spacing_result ret;
+  if (simple_state_.empty ())
+    return ret;
+
   ret.penalty_ = simple_state_.back ().penalty_
                  + lines_.back ().page_penalty_ + lines_.back ().turn_penalty_;
   ret.system_count_status_ = simple_state_.back ().system_count_status_;
index 88ebae09d85c4714e318013bbf5d6a5c8541a452..61afdb9bcc281004c4b0dbffbabe2fbd757ec4d5 100644 (file)
@@ -370,9 +370,12 @@ get_column_description (vector<Grob *> const &cols, vsize col_index, bool line_s
   if (next_col)
     description.spring_ = Spaceable_grob::get_spring (col, next_col);
 
-  Grob *end_col = dynamic_cast<Item *> (cols[col_index + 1])->find_prebroken_piece (LEFT);
-  if (end_col)
-    description.end_spring_ = Spaceable_grob::get_spring (col, end_col);
+  if (col_index + 1 < cols.size ())
+    {
+      Grob *end_col = dynamic_cast<Item *> (cols[col_index + 1])->find_prebroken_piece (LEFT);
+      if (end_col)
+        description.end_spring_ = Spaceable_grob::get_spring (col, end_col);
+    }
 
   for (SCM s = Spaceable_grob::get_minimum_distances (col);
        scm_is_pair (s); s = scm_cdr (s))