]> git.donarmstrong.com Git - lilypond.git/commitdiff
Handle situations that either one of above and below is a valid
authorHan-Wen Nienhuys <hanwen@lilypond.org>
Mon, 18 Apr 2011 02:47:29 +0000 (23:47 -0300)
committerCarl Sorensen <c_sorensen@byu.edu>
Sat, 30 Apr 2011 03:41:49 +0000 (21:41 -0600)
configuration in Beam::shift_region_to_valid().

This fixes the regression introduced in
bf707a03756021f69e3f5d1a8246639a6a601099, leading to random quanting
(-O2 build) or crashes (debug build.)

lily/beam.cc

index 6845b1346be59a2eefe2b3499965057993ee1b69..627ffac0f0f06b4a934ee98c7bbfb994ed4f3f6d 100644 (file)
@@ -1299,14 +1299,24 @@ Beam::shift_region_to_valid (SCM grob, SCM posns)
     {
       // We're good to go. Do nothing.
     }
+  else if (collision_free[DOWN].is_empty() != collision_free[UP].is_empty())
+    {
+      // Only one of them offers is feasible solution. Pick that one.
+      Interval v =
+        (!collision_free[DOWN].is_empty()) ?
+        collision_free[DOWN] : 
+        collision_free[UP];
+
+      beam_left_y = point_in_interval (v, 2.0);
+    }
   else if (!collision_free[DOWN].is_empty ()
-           || !collision_free[UP].is_empty ())
+           && !collision_free[UP].is_empty ())
     {
-      // We have space above or below collisions (or, no collisions at
-      // all).  Should we factor in the size of the collision_free
-      // interval as well?
+      // Above and below are candidates, take the one closest to the
+      // starting solution.
       Interval best =  
-        (collision_free[DOWN].distance(beam_left_y) < collision_free[UP].distance (beam_left_y)) ?
+        (collision_free[DOWN].distance (beam_left_y)
+         < collision_free[UP].distance (beam_left_y)) ?
         collision_free[DOWN] : collision_free[UP];
 
       beam_left_y = point_in_interval (best, 2.0);