From 57fb00d533fe0ff0604675a295ead6cb18ac4ff6 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 4 Jun 2020 13:51:39 +0300 Subject: [PATCH] Fix for #21537 : Dumped file not loadable --- src/Model/Model_AttributeSelection.cpp | 31 +++++++++++++++------ src/Model/Model_AttributeSelection.h | 3 +- src/ModelHighAPI/ModelHighAPI_Interface.cpp | 5 +++- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 68c9c3203..3badb0068 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -1316,7 +1316,8 @@ void Model_AttributeSelection::computeValues( void Model_AttributeSelection::concealedFeature( const FeaturePtr theFeature, const FeaturePtr theStop, const bool theCheckCopy, - std::list& theConcealers, const ResultPtr theResultOfFeature) + std::list& theConcealers, const ResultPtr theResultOfFeature, + const bool theCheckWholeFeature) { std::set alreadyProcessed; alreadyProcessed.insert(theFeature); @@ -1332,16 +1333,21 @@ void Model_AttributeSelection::concealedFeature( } std::list::const_iterator aRootIter = aRootRes.cbegin(); for(; aRootIter != aRootRes.cend(); aRootIter++) { - std::list allRes; - allRes.push_back(*aRootIter); + std::list allRes; + allRes.push_back((*aRootIter)->data()); ResultBodyPtr aRootBody = ModelAPI_Tools::bodyOwner(*aRootIter, true); if (!aRootBody.get()) aRootBody = std::dynamic_pointer_cast(*aRootIter); if (aRootBody.get()) { - ModelAPI_Tools::allSubs(aRootBody, allRes); - } - for(std::list::iterator aRIter = allRes.begin(); aRIter != allRes.end(); aRIter++) { - const std::set& aRefs = (*aRIter)->data()->refsToMe(); + std::list allSub; + ModelAPI_Tools::allSubs(aRootBody, allSub); + for(std::list::iterator anIt = allSub.begin(); anIt != allSub.end(); anIt++) + allRes.push_back((*anIt)->data()); + } + if (theCheckWholeFeature) + allRes.push_back(theFeature->data()); + for(std::list::iterator aRIter = allRes.begin(); aRIter != allRes.end(); aRIter++) { + const std::set& aRefs = (*aRIter)->refsToMe(); std::set::const_iterator aRef = aRefs.cbegin(); for (; aRef != aRefs.cend(); aRef++) { if (!aRef->get() || !(*aRef)->owner().get()) @@ -2094,8 +2100,15 @@ ResultPtr Model_AttributeSelection::newestContext( } // in case sketch line was selected for wire, but wire was concealed and not such line anymore, // so, actually, the sketch element was selected (which is never concealed) - if (aResult != theCurrent && aResult->isConcealed()) - aResult = theCurrent; + if (aResult != theCurrent && theCurrent->groupName() == ModelAPI_ResultConstruction::group()) { + //&& aResult->isConcealed()) + std::list aConcealers; + FeaturePtr aResFeature = aDoc->feature(aResult); + FeaturePtr aThisFeature = std::dynamic_pointer_cast(owner()); + concealedFeature(aResFeature, aThisFeature, false, aConcealers, aResult, true); + if (aConcealers.size()) + aResult = theCurrent; + } return aResult; } diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 0b1af7181..193f2d1dd 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -209,7 +209,8 @@ protected: /// theResultOfFeature if not null defines exact referenced result of a feature void concealedFeature( const FeaturePtr theFeature, const FeaturePtr theStop, const bool theCheckCopy, - std::list& theConcealers, const ResultPtr theResultOfFeature); + std::list& theConcealers, const ResultPtr theResultOfFeature, + const bool theCheckWholeFeature = false); friend class Model_Data; friend class Model_AttributeSelectionList; diff --git a/src/ModelHighAPI/ModelHighAPI_Interface.cpp b/src/ModelHighAPI/ModelHighAPI_Interface.cpp index 9555b977d..cec0fb1ce 100644 --- a/src/ModelHighAPI/ModelHighAPI_Interface.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Interface.cpp @@ -88,8 +88,11 @@ void ModelHighAPI_Interface::execute(bool isForce) void ModelHighAPI_Interface::setName(const std::string& theName) { - if (feature().get()) + if (feature().get() && feature()->data()->isValid()) feature()->data()->setName(theName); + else { + std::cout<<"Error: set name "<