From 27694200e7c0c69329eb2a16ff8343f6e3bd4d16 Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 22 May 2015 12:15:41 +0300 Subject: [PATCH] Fix for internal setting of current feature --- src/Model/Model_Document.cpp | 15 +++++---------- src/Model/Model_Objects.cpp | 4 +--- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 985c401ae..df85c6e4b 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -449,9 +449,9 @@ void Model_Document::undoInternal(const bool theWithSubs, const bool theSynchron } // after redo of all sub-documents to avoid updates on not-modified data (issue 370) if (theSynchronize) { + myObjs->synchronizeFeatures(true, true, isRoot()); // update the current features status setCurrentFeature(currentFeature(false), false); - myObjs->synchronizeFeatures(true, true, isRoot()); } } @@ -489,10 +489,10 @@ void Model_Document::redo() for (; aSubIter != aSubs.end(); aSubIter++) subDoc(*aSubIter)->redo(); - // update the current features status - setCurrentFeature(currentFeature(false), false); // after redo of all sub-documents to avoid updates on not-modified data (issue 370) myObjs->synchronizeFeatures(true, true, isRoot()); + // update the current features status + setCurrentFeature(currentFeature(false), false); } std::list Model_Document::undoList() const @@ -567,13 +567,8 @@ void Model_Document::removeFeature(FeaturePtr theFeature) { // if this feature is current, make the current the previous feature if (theFeature == currentFeature(false)) { - int aCurrentIndex = index(theFeature); - if (aCurrentIndex != -1) { - ObjectPtr aPrevObj; - if (aCurrentIndex != 0) - aPrevObj = object(ModelAPI_Feature::group(), aCurrentIndex - 1); - setCurrentFeature(std::dynamic_pointer_cast(aPrevObj), false); - } + FeaturePtr aPrev = myObjs->nextFeature(theFeature, true); + setCurrentFeature(aPrev, false); } myObjs->removeFeature(theFeature); } diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 2356a2053..98ead6c68 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -227,9 +227,7 @@ void Model_Objects::removeFeature(FeaturePtr theFeature) // erase all attributes under the label of feature aFeatureLabel.ForgetAllAttributes(); // remove it from the references array - if (theFeature->isInHistory()) { - RemoveFromRefArray(featuresLabel(), aFeatureLabel); - } + RemoveFromRefArray(featuresLabel(), aFeatureLabel); // event: feature is deleted ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group()); // the redisplay signal should be flushed in order to erase the feature presentation in the viewer -- 2.39.2