X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeValidator.cpp;h=d29834c93991906f7be59c5141d908c846f28079;hb=6dce44a08e0505613a25d6d093f153d69045b1ce;hp=ab01428148b1f47f90fab019e49e2182233914a0;hpb=bb35f30445789d765cdc106da40efb95cce7a41f;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeValidator.cpp b/src/Model/Model_AttributeValidator.cpp index ab0142814..d29834c93 100644 --- a/src/Model/Model_AttributeValidator.cpp +++ b/src/Model/Model_AttributeValidator.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2020 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -32,7 +32,7 @@ #include bool Model_AttributeValidator::isValid(const AttributePtr& theAttribute, - const std::list& theArguments, + const std::list& /*theArguments*/, Events_InfoMessage& theError) const { if (theAttribute->attributeType() == ModelAPI_AttributeInteger::typeId()) { @@ -101,6 +101,8 @@ bool Model_AttributeValidator::isValid(const AttributePtr& theAttribute, std::list::const_iterator aRefIter = aReferencedList.cbegin(); for(; aRefIter != aReferencedList.cend(); aRefIter++) { const ObjectPtr& aReferenced = *aRefIter; + if (!aReferenced.get()) + continue; // get all results and feature that is referenced to see all references to them FeaturePtr aReferencedFeature; if (aReferenced->groupName() == ModelAPI_Feature::group()) { @@ -112,8 +114,21 @@ bool Model_AttributeValidator::isValid(const AttributePtr& theAttribute, if (alreadyProcessed.count(aReferencedFeature)) continue; alreadyProcessed.insert(aReferencedFeature); + /* it takes all results, not only concealed std::list aReferencedResults; ModelAPI_Tools::allResults(aReferencedFeature, aReferencedResults); + */ + std::list aReferencedResults; + ResultBodyPtr aRefBody = std::dynamic_pointer_cast(aReferenced); + if (aRefBody.get()) { // take only sub-results of this result or sub-result + ResultBodyPtr aRoot = ModelAPI_Tools::bodyOwner(aRefBody, true); + if (aRoot.get()) { + ModelAPI_Tools::allSubs(aRoot, aReferencedResults, false); + aReferencedResults.push_back(aRoot); + } else + aReferencedResults.push_back(aRefBody); + } + std::list::iterator aRefRes = aReferencedResults.begin(); bool aCheckFeature = true; // the last iteration to check the feature while(aRefRes != aReferencedResults.end() || aCheckFeature) { @@ -121,6 +136,9 @@ bool Model_AttributeValidator::isValid(const AttributePtr& theAttribute, if (aRefRes == aReferencedResults.end()) { aRefd = aReferencedFeature; aCheckFeature = false; + if (!aReferencedFeature->results().empty() && + aReferencedFeature->firstResult()->groupName() != ModelAPI_ResultBody::group()) + break; } else { aRefd = *aRefRes; if (aRefd->groupName() != ModelAPI_ResultBody::group()) @@ -136,9 +154,13 @@ bool Model_AttributeValidator::isValid(const AttributePtr& theAttribute, continue; if (ModelAPI_Session::get()->validators()->isConcealed( aRefFeat->getKind(), (*aRR)->id())) { - theError = "Reference to concealed object %1"; - theError.arg(aRefd->data()->name()); - return false; + // check this feature is later than another referenced to make unit tests working + //because of Test1757 and others: allow to move selection context of this to next + if (aFeat->document()->isLater(aFeat, aRefFeat)) { + theError = "Reference to concealed object %1"; + theError.arg(aRefd->data()->name()); + return false; + } } } if (aCheckFeature)