From 443f4864dbf4d3718baf0bddda97678949eb62a1 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Wed, 13 Nov 2024 16:41:46 +0100 Subject: [PATCH] Fix CMME importer crash with chord within ligature --- src/iocmme.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/iocmme.cpp b/src/iocmme.cpp index daa3a3a1bf..ab0689e8e0 100644 --- a/src/iocmme.cpp +++ b/src/iocmme.cpp @@ -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)