Abjad / abjad

Abjad is a Python API for building LilyPond files. Use Abjad to make PDFs of music notation.
https://abjad.github.io
GNU General Public License v3.0
234 stars 41 forks source link

Fix wrapper update (after context has been removed) #1532

Closed trevorbaca closed 1 year ago

trevorbaca commented 1 year ago

Consider the following:

def main():
    voice = abjad.Voice("c'4")
    staff = abjad.Staff([voice])
    score = abjad.Score([staff])
    leaf = abjad.select.leaf(staff, 0)
    mark = abjad.MetronomeMark((1, 4), 72)
    abjad.attach(mark, leaf)
    score[:] = []
    string = abjad.lilypond(staff)
    print(string)

This gives:

Traceback (most recent call last):
  File "/Users/trevor/.abjad/tmp.py", line 18, in <module>
    main()
  File "/Users/trevor/.abjad/tmp.py", line 15, in main
    string = abjad.lilypond(staff)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trevor/abjad/abjad/illustrators.py", line 345, in lilypond
    string = argument._get_lilypond_format()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trevor/abjad/abjad/score.py", line 263, in _get_lilypond_format
    _updatelib._update_now(self, indicators=True)
  File "/Users/trevor/abjad/abjad/_updatelib.py", line 385, in _update_now
    _update_all_indicators(root)
  File "/Users/trevor/abjad/abjad/_updatelib.py", line 239, in _update_all_indicators
    wrapper._update_effective_context()
  File "/Users/trevor/abjad/abjad/bind.py", line 406, in _update_effective_context
    self._bind_effective_context(correct_effective_context)
  File "/Users/trevor/abjad/abjad/bind.py", line 344, in _bind_effective_context
    correct_effective_context._update_later(offsets_in_seconds=True)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute '_update_later'

Fix this so that the abjad.MetronomeMark wrapper updates correctly without a stacktrace.