From: Reinhold Kainhofer Date: Fri, 7 Nov 2008 11:54:50 +0000 (+0100) Subject: MusicXML: Fix clefs that appear in only one staff (ignore for the other!) X-Git-Tag: release/2.11.64-1~77 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e34fa906a662074ff2b650ec5219b6aa387d3c08;p=lilypond.git MusicXML: Fix clefs that appear in only one staff (ignore for the other!) This bug caused a position-off problem, which messed up chord detection and caused several other problems. If a clef has a number attribute (indicating its staff number), only copy it to the relevant staff. For all other staves, if the remaining attributes are empty, simply ignore them instead of passing an emtpy tag, which was the real cause for the problem. --- diff --git a/python/musicxml.py b/python/musicxml.py index 496b82b405..a7cf59730f 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -613,12 +613,17 @@ class Part (Music_xml_node): # modify attributes so that only those applying to the given staff remain def extract_attributes_for_staff (part, attr, staff): attributes = copy.copy (attr) - attributes._children = copy.copy (attr._children) + attributes._children = []; attributes._dict = attr._dict.copy () - for c in attributes._children: - if hasattr (c, 'number') and c.number != staff: - attributes._children.remove (c) - return attributes + # copy only the relevant children over for the given staff + for c in attr._children: + if (not (hasattr (c, 'number') and (c.number != staff)) and + not (isinstance (c, Hash_text))): + attributes._children.append (c) + if not attributes._children: + return None + else: + return attributes def extract_voices (part): voices = {} @@ -680,8 +685,9 @@ class Part (Music_xml_node): # assign these only to the voices they really belongs to! for (s, vids) in staff_to_voice_dict.items (): staff_attributes = part.extract_attributes_for_staff (n, s) - for v in vids: - voices[v].add_element (staff_attributes) + if staff_attributes: + for v in vids: + voices[v].add_element (staff_attributes) continue if isinstance (n, Partial) or isinstance (n, Barline):