From 8dec2cb7a478a72bd503179acfa55379acf052fc Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 27 May 2015 11:01:27 +0300 Subject: [PATCH] Fix on floating bug on abort of parameter creation --- src/Model/Model_Objects.cpp | 4 ++-- src/ModelAPI/ModelAPI_Feature.cpp | 21 +++++++++++++++++++++ src/ModelAPI/ModelAPI_Feature.h | 3 +++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 9ca1a15d4..c53cdc23f 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -759,10 +759,10 @@ void Model_Objects::updateResults(FeaturePtr theFeature) std::list::const_iterator aResIter = theFeature->results().cbegin(); while(aResIter != theFeature->results().cend()) { ResultPtr aBody = std::dynamic_pointer_cast(*aResIter); - if (aBody) { + if (aBody.get()) { if (!aBody->data()->isValid()) { // found a disappeared result => remove it - theFeature->removeResult(aBody); + theFeature->eraseResultFromList(aBody); // start iterate from beginning because iterator is corrupted by removing aResIter = theFeature->results().cbegin(); continue; diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp index ba51db260..e6c784426 100644 --- a/src/ModelAPI/ModelAPI_Feature.cpp +++ b/src/ModelAPI/ModelAPI_Feature.cpp @@ -80,6 +80,27 @@ void ModelAPI_Feature::removeResult(const std::shared_ptr& theR aLoop->flush(aRedispEvent); } +void ModelAPI_Feature::eraseResultFromList(const std::shared_ptr& theResult) +{ + std::list >::iterator aResIter = myResults.begin(); + for(; aResIter != myResults.end(); aResIter++) { + ResultPtr aRes = *aResIter; + if (aRes == theResult) { + std::string aGroup = aRes->groupName(); + aRes->data()->erase(); + myResults.erase(aResIter); + + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED); + static Events_Loop* aLoop = Events_Loop::loop(); + static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); + static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); + ModelAPI_EventCreator::get()->sendDeleted(document(), aGroup); + aECreator->sendUpdated(aRes, EVENT_DISP); + break; + } + } +} + void ModelAPI_Feature::removeResults(const int theSinceIndex, const bool theFlush) { std::list >::iterator aResIter = myResults.begin(); diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index 436a1adbf..8631c3e08 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -90,6 +90,9 @@ class ModelAPI_Feature : public ModelAPI_Object MODELAPI_EXPORT void eraseResults(); /// removes all fields from this feature: results, data, etc MODELAPI_EXPORT virtual void erase(); + /// removes the result from the list of feature (not doing in disabled): normally this + /// method is not used from features. only internally + MODELAPI_EXPORT void eraseResultFromList(const std::shared_ptr& theResult); /// Returns true if result is persistent (stored in document) and on undo-redo, save-open /// it is not needed to recompute it. -- 2.39.2