Salome HOME
Issue #632: Activate/Deactivate zoom tracking on activation/deactivation of module
[modules/shaper.git] / src / InitializationPlugin / InitializationPlugin_Plugin.cpp
index b2ced2b57b3ef5372fa45dbaf9ddcb9a3b316240..654b9c446e02cd44506916a8b6e5ac16241166f0 100644 (file)
@@ -55,17 +55,16 @@ void InitializationPlugin_Plugin::processEvent(const std::shared_ptr<Events_Mess
 
     // hides the created features, the precondition is that the feature's results have been
     // already built, so the createPlane/Points method calls the execute function for the planes
-    static Events_ID HIDE_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TOHIDE);
     std::list<FeaturePtr >::const_iterator aFIter = aFeatures.begin();
     for (; aFIter != aFeatures.cend(); aFIter++) {
       FeaturePtr aPlane = *aFIter;
       const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = aPlane->results();
       std::list<ResultPtr >::const_iterator aRIter = aResults.begin();
       for (; aRIter != aResults.cend(); aRIter++) {
-        ModelAPI_EventCreator::get()->sendUpdated(*aRIter, HIDE_DISP);
+        (*aRIter)->setDisplayed(false);
       }
     }
-    Events_Loop::loop()->flush(HIDE_DISP);
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
 
     // the viewer update should be unblocked in order to avoid the features blinking before they are
     // hidden
@@ -103,6 +102,10 @@ FeaturePtr InitializationPlugin_Plugin::createPlane(DocumentPtr theDoc, double t
   // the plane should be executed in order to build the feature result immediatelly
   // the results are to be hidden in the plugin
   aPlane->execute();
+  // this flag is needed here to avoid setting it inside of the next transaction
+  // (may cause crash on redo of the first transaction in OCAF)
+  aPlane->data()->execState(ModelAPI_StateDone);
+  aPlane->firstResult()->data()->execState(ModelAPI_StateDone);
 
   return aPlane;
 }
@@ -119,6 +122,8 @@ FeaturePtr InitializationPlugin_Plugin::createPoint(DocumentPtr theDoc)
   // the point should be executed in order to build the feature result immediatelly
   // the results are to be hidden in the plugin
   aPoint->execute();
+  aPoint->data()->execState(ModelAPI_StateDone);
+  aPoint->firstResult()->data()->execState(ModelAPI_StateDone);
 
   return aPoint;
 }