]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix on floating bug on abort of parameter creation
authormpv <mpv@opencascade.com>
Wed, 27 May 2015 08:01:27 +0000 (11:01 +0300)
committermpv <mpv@opencascade.com>
Wed, 27 May 2015 08:01:27 +0000 (11:01 +0300)
src/Model/Model_Objects.cpp
src/ModelAPI/ModelAPI_Feature.cpp
src/ModelAPI/ModelAPI_Feature.h

index 9ca1a15d4f740d66d1b97ff878a7e1ded76c9136..c53cdc23f10f997432b9437b914e2985b116c4aa 100644 (file)
@@ -759,10 +759,10 @@ void Model_Objects::updateResults(FeaturePtr theFeature)
   std::list<ResultPtr>::const_iterator aResIter = theFeature->results().cbegin();
   while(aResIter != theFeature->results().cend()) {
     ResultPtr aBody = std::dynamic_pointer_cast<ModelAPI_Result>(*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;
index ba51db2605a72c83429296ed85b6c782ddacf759..e6c784426bdf254646417e44b001005226fa6d1b 100644 (file)
@@ -80,6 +80,27 @@ void ModelAPI_Feature::removeResult(const std::shared_ptr<ModelAPI_Result>& theR
   aLoop->flush(aRedispEvent);
 }
 
+void ModelAPI_Feature::eraseResultFromList(const std::shared_ptr<ModelAPI_Result>& theResult)
+{
+  std::list<std::shared_ptr<ModelAPI_Result> >::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<std::shared_ptr<ModelAPI_Result> >::iterator aResIter = myResults.begin();
index 436a1adbfec81f98050d257a3084e5993634eafe..8631c3e08b2d53beb32c0ad5fb951e2e5064337a 100644 (file)
@@ -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<ModelAPI_Result>& theResult);
 
   /// Returns true if result is persistent (stored in document) and on undo-redo, save-open
   /// it is not needed to recompute it.