Skip to content

Commit

Permalink
Fix CMME importer crash with chord within ligature
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed Nov 13, 2024
1 parent ff6d77d commit 443f486
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/iocmme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,22 +524,28 @@ void CmmeInput::CreateBreak(pugi::xml_node breakNode)
void CmmeInput::CreateChord(pugi::xml_node chordNode)
{
assert(m_currentContainer);

Chord *chord = new Chord();
m_currentContainer->AddChild(chord);
m_currentContainer = chord;

// CMME can have 'chords' in ligatures - we keep only the first note
bool inLigature = (m_currentContainer->Is(LIGATURE));

if (!inLigature) {
Chord *chord = new Chord();
m_currentContainer->AddChild(chord);
m_currentContainer = chord;
}
pugi::xpath_node_set events = chordNode.select_nodes("./*");
for (pugi::xpath_node event : events) {
pugi::xml_node eventNode = event.node();
std::string name = eventNode.name();
if (name == "Note") {
CreateNote(eventNode);
if (inLigature) break;
}
else {
LogWarning("Unsupported chord component: '%s'", name.c_str());
}
}
m_currentContainer = m_currentContainer->GetParent();
if (!inLigature) m_currentContainer = m_currentContainer->GetParent();
}

void CmmeInput::CreateClef(pugi::xml_node clefNode)
Expand Down

0 comments on commit 443f486

Please sign in to comment.