From: Han-Wen Nienhuys Date: Mon, 17 Mar 2008 15:03:26 +0000 (-0300) Subject: Fix #587. X-Git-Tag: release/2.11.43-1~29^2~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0c3c8d7e6251e8851ef005c76413b787dfc8d9fd;p=lilypond.git Fix #587. Do not crash on null common element in Axis_group_interface::calc_[xy]_common --- diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 8f8e1b8893..8089d316f9 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -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 diff --git a/lily/include/axis-group-interface.hh b/lily/include/axis-group-interface.hh index 95c4901f34..f91771597e 100644 --- a/lily/include/axis-group-interface.hh +++ b/lily/include/axis-group-interface.hh @@ -40,6 +40,7 @@ struct Axis_group_interface static bool has_axis (Grob *, Axis); static void get_children (Grob *, vector *); static Interval staff_extent (Grob *me, Grob *ref, Axis, Grob *staff, Axis); + static SCM calc_common (Grob *, Axis); DECLARE_GROB_INTERFACE(); };