]> git.donarmstrong.com Git - lilypond.git/commitdiff
Avoid floating-point compares on Stem:head_positions; issue 4310
authorKeith OHara <k-ohara5a5a@oco.net>
Wed, 11 Mar 2015 04:04:13 +0000 (21:04 -0700)
committerKeith OHara <k-ohara5a5a@oco.net>
Fri, 20 Mar 2015 03:46:40 +0000 (20:46 -0700)
On the cross-compiled windows executable, head_positions().is_empty()
seems to sometimes return true for a stem with a single note.
head_positions() returns something like [3.00... , 3.00...]

lily/beam.cc
lily/stem.cc

index a9a19b38c72fae30731caa1f58dea78b65499a6d..83b0c743f950d6e396a278b6a537f5f1560b8669 100644 (file)
@@ -870,11 +870,11 @@ Beam::consider_auto_knees (Grob *me)
     {
       Grob *stem = stems[i];
 
-      Interval head_extents = Stem::head_positions (stem);
-      if (!head_extents.is_empty ())
+      Interval head_extents;
+      if (Stem::head_count (stem))
         {
-          head_extents[LEFT] += -1;
-          head_extents[RIGHT] += 1;
+          head_extents = Stem::head_positions (stem);
+          head_extents.widen (1);
           head_extents *= staff_space * 0.5;
 
           /*
index 045a90760b29d7e916f211e0c46322b99f433ea2..f21e0de6b5dac5b7dffbd0a3b1da25f4fcbb0562 100644 (file)
@@ -110,10 +110,10 @@ Stem::head_positions (Grob *me)
 Real
 Stem::chord_start_y (Grob *me)
 {
-  Interval hp = head_positions (me);
-  if (!hp.is_empty ())
-    return hp[get_grob_direction (me)] * Staff_symbol_referencer::staff_space (me)
-           * 0.5;
+  if (head_count (me))
+    return Staff_symbol_referencer::get_position (last_head (me))
+      * Staff_symbol_referencer::staff_space (me) * 0.5;
+
   return 0;
 }
 
@@ -658,9 +658,9 @@ Stem::calc_default_direction (SCM smob)
 
   Direction dir = CENTER;
   int staff_center = 0;
-  Interval hp = head_positions (me);
-  if (!hp.is_empty ())
+  if (head_count (me))
     {
+      Interval hp = head_positions (me);
       int udistance = (int) (UP * hp[UP] - staff_center);
       int ddistance = (int) (DOWN * hp[DOWN] - staff_center);