lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

report a programming error when trying to align on empty parent (issue 7


From: janek . lilypond
Subject: report a programming error when trying to align on empty parent (issue 7533046)
Date: Mon, 18 Mar 2013 14:18:34 +0000

Reviewers: dak, MikeSol, J_lowe,

Message:
This is the part of Issue 3239 that introduced additional programming
errors.  I hope that the explanation is clear.

Of course there is one fundamental question: maybe we shouldn't complain
about grobs with empty extents, and just silently assume that an empty
extent is equivalent to (0 . 0)?

In other words, maybe this fragment of code should never report any
programming errors?

Description:
report a programming error when trying to align on empty parent

To align grobs, we look at their extents (which are basically
grob dimensions in respective axes) and offset them according
to these extents.  If a grob's extent is empty (undefined),
we cannot calculate the offset required to achieve desired
alignment of this grob, so we report a "programming error:
cannot align on self: empty element".

It is acceptable to align a grob which dimension is 0 (for
example its stencil is just a point), but in that case its
extent should be a zero interval, not an undefined value
(i.e. (0 . 0), not #f).

If we want to align a grob on its parent, the required offset
is calculated based on extents of both the grob and the
parent, so the parent's extent shouldn't be empty as well.
This patch makes LilyPond report a programming error if
parent's extent is empty (until now such situations were just
silently ignored).

Please review this at https://codereview.appspot.com/7533046/

Affected files:
  M lily/self-alignment-interface.cc


Index: lily/self-alignment-interface.cc
diff --git a/lily/self-alignment-interface.cc b/lily/self-alignment-interface.cc index 59adfc3e6ca04d878349f6e3425843c703694c45..1ce24d77e387189b0d5b11c328f7edc1a53e623a 100644
--- a/lily/self-alignment-interface.cc
+++ b/lily/self-alignment-interface.cc
@@ -152,7 +152,9 @@ Self_alignment_interface::aligned_on_parent (Grob *me, Axis a)
   else
     x -= ext.linear_combination (align);

-  if (!he.is_empty ())
+  if (he.is_empty ())
+    programming_error ("cannot align on parent: empty element");
+  else
     x += he.linear_combination (align);

   return scm_from_double (x);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]