]> git.donarmstrong.com Git - lilypond.git/commitdiff
stem.cc: be robust in case of missing note-head stencils
authorKeith OHara <k-ohara5a5a@oco.net>
Sun, 16 Sep 2012 23:26:01 +0000 (16:26 -0700)
committerKeith OHara <k-ohara5a5a@oco.net>
Fri, 21 Sep 2012 04:18:51 +0000 (21:18 -0700)
lily/flag.cc
lily/grob.cc
lily/stem-tremolo.cc
lily/stem.cc

index 77491befd6df84fb3d922718f7c7d82bfa73a5ce..31ddf349c92cf1098836fa98b11252ea19cf2b00 100644 (file)
@@ -186,11 +186,13 @@ Flag::internal_calc_y_offset (SCM smob, bool pure)
   Real blot
     = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
 
-  Real y2 = pure
-            ? stem->pure_height (stem, 0, INT_MAX)[d]
-            : stem->extent (stem, Y_AXIS)[d];
+  Interval stem_extent = pure
+                         ? stem->pure_height (stem, 0, INT_MAX)
+                         : stem->extent (stem, Y_AXIS);
 
-  return scm_from_double (y2 - d * blot / 2);
+  return scm_from_double (stem_extent.is_empty ()
+                          ? 0.0
+                          : stem_extent[d] - d * blot / 2);
 }
 
 MAKE_SCHEME_CALLBACK (Flag, calc_x_offset, 1);
index c515c186169e16402ea38a5476e93f7e1ae5e7a5..031af32636878b3a163bb0ea483bca2e0d0fcdc5 100644 (file)
@@ -472,9 +472,11 @@ Grob::extent (Grob *refp, Axis a) const
     }
 
   // We never want nan, so we avoid shifting infinite values.
-  for (LEFT_and_RIGHT (d))
-    if (!isinf (real_ext[d]))
-      real_ext[d] += offset;
+    if(!isinf (offset))
+      real_ext.translate(offset);
+    else
+      this->warning(_f ("ignored infinite %s-offset",
+                        a == X_AXIS ? "X" : "Y"));
 
   return real_ext;
 }
index 5c5ee051d4a7bc582ae1baefdee604bbafc1d855..1f9d2d8a7a5b7568ed810f70936f5df8087f6b54 100644 (file)
@@ -314,7 +314,7 @@ Stem_tremolo::y_offset (Grob *me, bool pure)
     }
 
   bool whole_note = Stem::duration_log (stem) <= 0;
-  if (whole_note)
+  if (whole_note || isinf(end_y))
     {
       /* we shouldn't position relative to the end of the stem since the stem
          is invisible */
index 8069a456c814e48cf24bddec96bf9d8fae2279ac..7037b8869cdb2c59f9e4a356e5de3622bee704c1 100644 (file)
@@ -545,7 +545,8 @@ Stem::calc_positioning_done (SCM smob)
           = hed->extent (hed, X_AXIS).linear_combination (CENTER)
             - heads[i]->extent (heads[i], X_AXIS).linear_combination (CENTER);
 
-      heads[i]->translate_axis (amount, X_AXIS);
+      if (!isnan (amount)) // empty heads can produce NaN
+        heads[i]->translate_axis (amount, X_AXIS);
     }
   bool parity = true;
   Real lastpos = Real (Staff_symbol_referencer::get_position (heads[0]));
@@ -794,7 +795,8 @@ Stem::internal_calc_stem_begin_position (Grob *me, bool calc_beam)
       Real y_attach = Note_head::stem_attachment_coordinate (head, Y_AXIS);
 
       y_attach = head_height.linear_combination (y_attach);
-      pos += d * y_attach * 2 / ss;
+      if (!isinf (y_attach) && !isnan (y_attach)) // empty heads
+        pos += d * y_attach * 2 / ss;
     }
 
   return pos;
@@ -882,7 +884,7 @@ Stem::offset_callback (SCM smob)
 
       Direction d = get_grob_direction (me);
       Real real_attach = head_wid.linear_combination (d * attach);
-      Real r = real_attach;
+      Real r = isnan(real_attach)? 0.0: real_attach;
 
       /* If not centered: correct for stem thickness.  */
       string style = robust_symbol2string (f->get_property ("style"), "default");