]> git.donarmstrong.com Git - lilypond.git/commit
Issue 3072: Nested overrides get confused with multiple contexts in play
authorDavid Kastrup <dak@gnu.org>
Thu, 14 Aug 2014 20:20:35 +0000 (22:20 +0200)
committerDavid Kastrup <dak@gnu.org>
Fri, 22 Aug 2014 05:15:47 +0000 (07:15 +0200)
commit6d611627eaef3fb5c754bdde106cd16c1ed23f31
tree8c8fcfced510ad7e3636d23ef766c2a0d4cad6be
parente328b7a10ec1a4e13ba11104825bf54e027d0dd0
Issue 3072: Nested overrides get confused with multiple contexts in play

The main problem with nested overrides lies not as much with the
override (which can be done reasonably well) but rather with the
corresponding reverts.  Detecting and undoing a previously established
nested override by its effects on an alist, particularly when nested
overrides may be present at several different levels in several
different contexts and/or stack depths and may be undone in different
order from being established, is a complex problem.  It is complex
enough that it is not clear that a satisfactory solution does even
exist: at least LilyPond's implementation breaks down for a number of
test cases.

The approach of this implementation is to not even try reverting nested
overrides from looking at their effects on the final result.  Instead
nested overrides like

\override Staff.TextSpanner.bound-details.left.text = #"foo"

are not done by creating an assembled alist element for TextSpanner
looking like

(bound-details . ((left . ((text . "foo") ...)) ...))

with ... filled in from other parts of the alist (which may change
independently at a later point of time) but rather by using
(bound-details left text) itself as a key and thus storing

((bound-details left text) . "foo")

as the representation of the override.  Consequently, reverting an
override with the same nested property path is straightforward.  Neither
the action of overriding nor of reverting now require referring to or
updating any part of the property stack outside of the current context.

The downside is that an actual reference to the resulting grob alist
requires expanding the nested overrides at the time of creating a grob
or otherwise asking for ly:context-grob-properties.

Since issue 2507 encapsulated grob property access into the
Grob_property_info algorithm container structure relying on data stored
in context properties of elements of type Grob_properties, changing the
respective algorithms can be facilitated completely in those classes.

In order to provide similarly efficient access and reasonable caching
and just-in-time reevaluation of previously computed values,
Grob_properties needed to be significantly extended in size.
lily/context-property.cc
lily/include/context.hh
lily/nested-property.cc