From: azv Date: Wed, 6 Dec 2017 08:41:24 +0000 (+0300) Subject: Issue #2338: Fatal error when Move out before the Folder in saved or dumped study X-Git-Tag: V_2.10.0RC~100 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f7d322c707e2bc07463b3c85d798699511e2c9c8;p=modules%2Fshaper.git Issue #2338: Fatal error when Move out before the Folder in saved or dumped study Issue #2339: Move out after the Folder is wrong Correct processing composite features when moving out of the folder --- diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 1308ec27f..abbb5309d 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -1597,17 +1597,7 @@ bool Model_Objects::removeFromFolder( aFolderEndFeature = aFoundFolder->reference(ModelAPI_Folder::LAST_FEATURE_ID())->value(); } - FeaturePtr aFeatureToFind; - if (isExtractBeforeFolder) { - aFeatureToFind = theFeatures.back(); - // if the last feature is composite, obtain its last sub-feature for correct positioning of - // the folder in the reference array when theFeatures will be extracted before folder - CompositeFeaturePtr aComposite = - std::dynamic_pointer_cast(aFeatureToFind); - if (aComposite) - aFeatureToFind = aComposite->subFeature(aComposite->numberOfSubs() - 1); - } else - aFeatureToFind = theFeatures.front(); + FeaturePtr aFeatureToFind = isExtractBeforeFolder ? theFeatures.back() : theFeatures.front(); std::shared_ptr aData = std::static_pointer_cast(aFeatureToFind->data()); if (!aData || !aData->isValid()) @@ -1630,15 +1620,29 @@ bool Model_Objects::removeFromFolder( TDF_Label aFolderLabel = aData->label().Father(); TDF_Label aPrevFeatureLabel = aRefs->Value(aRefIndex); // update start reference of the folder - if (aFolderStartFeature.get()) - aFolderStartFeature = feature(aRefs->Value(aRefIndex + 1)); + if (aFolderStartFeature.get()) { + FeaturePtr aNewStartFeature; + do { // skip all features placed in the composite features + aPrevFeatureLabel = aRefs->Value(aRefIndex++); + aNewStartFeature = + aRefIndex <= aRefs->Upper() ? feature(aRefs->Value(aRefIndex)) : FeaturePtr(); + } while (aNewStartFeature && isSkippedFeature(aNewStartFeature)); + aFolderStartFeature = aNewStartFeature; + } // move the folder in the list of references after the last feature from the list RemoveFromRefArray(aFeaturesLab, aFolderLabel); AddToRefArray(aFeaturesLab, aFolderLabel, aPrevFeatureLabel); } else { // update end reference of the folder - if (aFolderEndFeature.get()) - aFolderEndFeature = feature(aRefs->Value(aRefIndex - 1)); + if (aFolderEndFeature.get()) { + FeaturePtr aNewEndFeature; + do { // skip all features placed in the composite features + --aRefIndex; + aNewEndFeature = + aRefIndex >= aRefs->Lower() ? feature(aRefs->Value(aRefIndex)) : FeaturePtr(); + } while (aNewEndFeature && isSkippedFeature(aNewEndFeature)); + aFolderEndFeature = aNewEndFeature; + } } // update folder references