]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 380: Try to auto-detect cyclic references in header fields
authorReinhold Kainhofer <reinhold@kainhofer.com>
Fri, 9 Sep 2011 16:46:25 +0000 (18:46 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 19 Sep 2011 10:35:51 +0000 (12:35 +0200)
Inside \fromproperty, simply change the props so that all references to the
currently interpreted property point to a function that prints out
a warning and returns a null markup, while interpreting the contents
of the property.

This is a specialized case of the cycle detection, since the hare+
tortoise algorithm does not tell us where the cycle was causes.
For properties we have a simple way to detect cyclic dependencies,
so we can tell the user which definition caused the problem.

scm/define-markup-commands.scm

index 88a9e9c7aa32198c24d6bad0b686e2e14b56850d..803b691215cf864950838d7280fecb1731968c7b 100644 (file)
@@ -1883,6 +1883,14 @@ Add padding @var{amount} around @var{arg} in the X@tie{}direction.
 ;; property
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
+(define-markup-command (property-recursive layout props symbol)
+  (symbol?)
+  #:category other
+  "Print out a warning when a header field markup contains some recursive
+markup definition."
+  (ly:warning "Recursive definition of property ~a detected!" symbol)
+  empty-stencil)
+
 (define-markup-command (fromproperty layout props symbol)
   (symbol?)
   #:category other
@@ -1905,7 +1913,8 @@ returns an empty markup.
 @end lilypond"
   (let ((m (chain-assoc-get symbol props)))
     (if (markup? m)
-        (interpret-markup layout props m)
+        ;; prevent infinite loops by clearing the interpreted property:
+        (interpret-markup layout (cons (list (cons symbol `(,property-recursive-markup ,symbol))) props) m)
         empty-stencil)))
 
 (define-markup-command (on-the-fly layout props procedure arg)