From 13edfd8b66adf9c10df01854b4340f6b72e07a60 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 29 Oct 2018 12:14:02 +0300 Subject: [PATCH] Issue #2690: Check folders attributes on delete of the folder --- src/PartSet/PartSet_Tools.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 020c47a27..0d91654e5 100755 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -757,6 +757,9 @@ ResultPtr PartSet_Tools::createFixedByExternalCenter( void PartSet_Tools::getFirstAndLastIndexInFolder(const ObjectPtr& theFolder, int& theFirst, int& theLast) { + theFirst = -1; + theLast = -1; + DocumentPtr aDoc = theFolder->document(); FolderPtr aFolder = std::dynamic_pointer_cast(theFolder); if (!aFolder.get()) @@ -764,18 +767,19 @@ void PartSet_Tools::getFirstAndLastIndexInFolder(const ObjectPtr& theFolder, AttributeReferencePtr aFirstFeatAttr = aFolder->data()->reference(ModelAPI_Folder::FIRST_FEATURE_ID()); + if (!aFirstFeatAttr.get()) + return; FeaturePtr aFirstFeatureInFolder = ModelAPI_Feature::feature(aFirstFeatAttr->value()); - if (!aFirstFeatureInFolder.get()) { - theFirst = -1; + if (!aFirstFeatureInFolder.get()) return; - } + AttributeReferencePtr aLastFeatAttr = aFolder->data()->reference(ModelAPI_Folder::LAST_FEATURE_ID()); + if (!aLastFeatAttr.get()) + return; FeaturePtr aLastFeatureInFolder = ModelAPI_Feature::feature(aLastFeatAttr->value()); - if (!aLastFeatureInFolder.get()) { - theLast = -1; + if (!aLastFeatureInFolder.get()) return; - } theFirst = aDoc->index(aFirstFeatureInFolder); theLast = aDoc->index(aLastFeatureInFolder); -- 2.39.2