From 4ab125400ff3bb9f018cc558ee1f9d5d90c75f65 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 12 Oct 2017 15:26:07 +0300 Subject: [PATCH] Fix the problem that for Remove Shapes the sub-result can be selected as a base object. In case of compound of compsolids and other kinds of shapes this may lead to crash. --- src/FeaturesPlugin/remove_subshapes_widget.xml | 2 +- src/GeomValidators/GeomValidators_BodyShapes.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/FeaturesPlugin/remove_subshapes_widget.xml b/src/FeaturesPlugin/remove_subshapes_widget.xml index b2698e274..353881c45 100644 --- a/src/FeaturesPlugin/remove_subshapes_widget.xml +++ b/src/FeaturesPlugin/remove_subshapes_widget.xml @@ -27,7 +27,7 @@ email : webmaster.salome@opencascade.com - + #include #include +#include bool GeomValidators_BodyShapes::isValid(const AttributePtr& theAttribute, const std::list& theArguments, @@ -46,6 +47,13 @@ bool GeomValidators_BodyShapes::isValid(const AttributePtr& theAttribute, theError = "Error: Result construction selected."; return false; } + // additional check that the selected object is top-level result + if (theArguments.size() > 0 && *(theArguments.rbegin()) == "toplevel") { + if (ModelAPI_Tools::compSolidOwner(aContext).get()) { + theError = "Error: Only higher level shape allowed."; + return false; + } + } } else if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) { AttributeSelectionListPtr anAttrSelectionList = std::dynamic_pointer_cast(theAttribute); -- 2.39.2