From c940201f2ffcfb713206b47e73cfa105e4aefb29 Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Fri, 25 Sep 2020 16:23:41 +0300 Subject: [PATCH] Issue #20101: SIGSEGV after validating extrusion Compatibility with old versions of SHAPER documents. --- .../FeaturesPlugin_CompositeSketch.cpp | 12 ++++++++++-- src/FeaturesPlugin/FeaturesPlugin_Validators.cpp | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp index ab0d12b7d..0bd58e26c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp @@ -32,6 +32,8 @@ #include +static const std::string COMPOSITESKETCH_VERSION_1("v9.6"); + static void storeSubShape(const std::shared_ptr theMakeShape, ResultBodyPtr theResultBody, const GeomShapePtr theShape, @@ -49,9 +51,15 @@ void FeaturesPlugin_CompositeSketch::initCompositeSketchAttribtues(const int the // Initialize selection list. if(theInitFlags & InitBaseObjectsList) { - data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId()); + AttributeSelectionListPtr anObjectsAttr = + std::dynamic_pointer_cast( + data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId())); myCurrentSelectionType = selectionList(BASE_OBJECTS_ID())->selectionType(); - selectionList(BASE_OBJECTS_ID())->setWholeResultAllowed(true); + anObjectsAttr->setWholeResultAllowed(true); + if (!anObjectsAttr->isInitialized()) { + // new feature, specify the version + data()->setVersion(COMPOSITESKETCH_VERSION_1); + } } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index 9235d933e..55bad81ce 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -402,7 +402,11 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute AttributeSelectionListPtr aListAttr = std::dynamic_pointer_cast(theAttribute); - const std::string& aSelType = aListAttr->selectionType(); + const std::string& aVersion = theAttribute->owner()->data()->version(); + std::string aSelType; + if (!aVersion.empty()) + aSelType = aListAttr->selectionType(); + std::list anApplicableTypes; switch (GeomValidators_ShapeType::shapeType(aSelType)) { case GeomValidators_ShapeType::Vertex: -- 2.39.2