]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #587.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 17 Mar 2008 15:03:26 +0000 (12:03 -0300)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 17 Mar 2008 15:03:26 +0000 (12:03 -0300)
Do not crash on null common element in Axis_group_interface::calc_[xy]_common

lily/axis-group-interface.cc
lily/include/axis-group-interface.hh

index 8f8e1b8893697f2513f93a3acb5375e081b348d1..8089d316f948ac0e25b5f834a5ca8f7d72d94a63 100644 (file)
@@ -385,26 +385,33 @@ Axis_group_interface::calc_pure_elts_and_common (Grob *me)
   return common;
 }
 
-MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_x_common, 1);
 SCM
-Axis_group_interface::calc_x_common (SCM grob)
+Axis_group_interface::calc_common (Grob *me, Axis axis)
 {
-  Grob *me = unsmob_grob (grob);
-
   extract_grob_set (me, "elements", elts);
-  Grob *common = common_refpoint_of_array (elts, me, X_AXIS);
+  Grob *common = common_refpoint_of_array (elts, me, axis);
+  if (!common)
+    {
+      me->programming_error ("No common parent found in calc_common axis.");
+      return SCM_EOL;
+    }
+  
   return common->self_scm ();
 }
 
+
+MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_x_common, 1);
+SCM
+Axis_group_interface::calc_x_common (SCM grob)
+{
+  return calc_common (unsmob_grob (grob), X_AXIS);
+}
+
 MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_y_common, 1);
 SCM
 Axis_group_interface::calc_y_common (SCM grob)
 {
-  Grob *me = unsmob_grob (grob);
-
-  extract_grob_set (me, "elements", elts);
-  Grob *common = common_refpoint_of_array (elts, me, Y_AXIS);
-  return common->self_scm ();
+  return calc_common (unsmob_grob (grob), Y_AXIS);
 }
 
 Interval
index 95c4901f34229261facf30338a72dc9b1c651771..f91771597ef65fc331477a0fb662f19aa0988353 100644 (file)
@@ -40,6 +40,7 @@ struct Axis_group_interface
   static bool has_axis (Grob *, Axis);
   static void get_children (Grob *, vector<Grob*> *);
   static Interval staff_extent (Grob *me, Grob *ref, Axis, Grob *staff, Axis);
+  static SCM calc_common (Grob *, Axis);
   DECLARE_GROB_INTERFACE();
 };