From 66336fc72e87ce33e82bb604caa7049f1084f971 Mon Sep 17 00:00:00 2001 From: Keith OHara Date: Tue, 10 Mar 2015 21:04:13 -0700 Subject: [PATCH] Avoid floating-point compares on Stem:head_positions; issue 4310 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 | 8 ++++---- lily/stem.cc | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lily/beam.cc b/lily/beam.cc index a9a19b38c7..83b0c743f9 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -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; /* diff --git a/lily/stem.cc b/lily/stem.cc index 045a90760b..f21e0de6b5 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -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); -- 2.39.5