diff options
-rw-r--r-- | slicer/xml/serializer.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/slicer/xml/serializer.cpp b/slicer/xml/serializer.cpp index 1ffa897..acbb83d 100644 --- a/slicer/xml/serializer.cpp +++ b/slicer/xml/serializer.cpp @@ -407,16 +407,19 @@ namespace Slicer { mp->GetValue(XmlContentValueTarget(cec)); } else if (mp->HasValue()) { - auto typeIdPropName = mp->GetTypeIdProperty(); - auto typeId = mp->GetTypeId(); - auto element = cec.get(); - if (typeId && typeIdPropName) { - element->set_attribute(*typeIdPropName, *typeId); - mp = mp->GetSubclassModelPart(*typeId); + auto oec = [element = cec.get(), &ec](const auto & lmp) { + lmp->OnEachChild([element, &ec](auto && PH1, auto && PH2, auto && PH3) { + return XmlSerializer::ModelTreeIterate(element, PH1, PH2, PH3, ec); + }); + return element; + }; + if (auto typeIdPropName = mp->GetTypeIdProperty()) { + if (auto typeId = mp->GetTypeId()) { + oec(mp->GetSubclassModelPart(*typeId))->set_attribute(*typeIdPropName, *typeId); + return; + } } - mp->OnEachChild([element, ec](auto && PH1, auto && PH2, auto && PH3) { - return XmlSerializer::ModelTreeIterate(element, PH1, PH2, PH3, ec); - }); + oec(mp); } } |