Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / XGUI / XGUI_WorkshopListener.cpp
index 218058a696eed4368754a1358d626941e1ada375..7701c221b70b1375a1764282380bbd044b4063f3 100755 (executable)
@@ -38,7 +38,6 @@
 #include <ModelAPI_Result.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
-#include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_Tools.h>
 
 #include <ModuleBase_Events.h>
@@ -83,7 +82,7 @@
 const std::string DebugFeatureKind = "";//"Extrusion";
 #endif
 
-XGUI_WorkshopListener::XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop)
+XGUI_WorkshopListener::XGUI_WorkshopListener(XGUI_Workshop* theWorkshop)
   : myWorkshop(theWorkshop),
     myUpdatePrefs(false)
 {
@@ -114,12 +113,15 @@ void XGUI_WorkshopListener::initializeEventListening()
 
   aLoop->registerListener(this, Events_Loop::eventByName("FinishOperation"));
   aLoop->registerListener(this, Events_Loop::eventByName("AbortOperation"));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE));
 }
 
 //******************************************************
 void XGUI_WorkshopListener::processEvent(const std::shared_ptr<Events_Message>& theMessage)
 {
-  if (QApplication::instance()->thread() != QThread::currentThread()) {
+  if (QApplication::instance() &&
+      QApplication::instance()->thread() != QThread::currentThread()) {
     #ifdef _DEBUG
     std::cout << "XGUI_Workshop::processEvent: " << "Working in another thread." << std::endl;
     #endif
@@ -161,8 +163,8 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr<Events_Message>&
       if (aWidgetSelector)
         workshop()->selector()->setSelected(aWidgetSelector->getAttributeSelection());
     }
-  } else if (theMessage->eventID() == Events_Loop::eventByName("FinishOperation") ||
-             theMessage->eventID() == Events_Loop::eventByName("AbortOperation"))
+  } else if (theMessage->eventID() == Events_Loop::eventByName("FinishOperation")/* ||
+             theMessage->eventID() == Events_Loop::eventByName("AbortOperation")*/)
     workshop()->facesPanel()->reset(false); // do not flush redisplay, it is flushed after event
 
   //Update property panel on corresponding message. If there is no current operation (no
@@ -184,6 +186,11 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr<Events_Message>&
     // the viewer's update context is unblocked, the viewer's update works
     XGUI_Displayer* aDisplayer = workshop()->displayer();
     aDisplayer->enableUpdateViewer(true);
+  } else if ((theMessage->eventID() ==
+    Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE)) ||
+    (theMessage->eventID() ==
+      Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE))) {
+    myWorkshop->updateAutoComputeState();
   } else {
     //Show error dialog if error message received.
     std::shared_ptr<Events_InfoMessage> anIngfoMsg =
@@ -524,6 +531,5 @@ bool XGUI_WorkshopListener::customizeCurrentObject(const std::set<ObjectPtr>& th
 
 XGUI_Workshop* XGUI_WorkshopListener::workshop() const
 {
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
-  return aConnector->workshop();
+  return myWorkshop;
 }