]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix SIGSEGV on model.checkPythonDump() in GUI
authorjfa <jfa@opencascade.com>
Thu, 27 Oct 2022 11:02:45 +0000 (14:02 +0300)
committerjfa <jfa@opencascade.com>
Thu, 27 Oct 2022 11:02:45 +0000 (14:02 +0300)
src/Model/Model_Session.cpp
src/ModelAPI/ModelAPI_Events.h
src/PartSet/PartSet_Module.cpp

index 37224746df949fbab6501ac844ccf2c02bef9e08..2ca754f7983d77ba6a555e42b3eb47fb8be80b00 100644 (file)
@@ -73,11 +73,11 @@ bool Model_Session::save(const char* theFileName, std::list<std::string>& theRes
 void Model_Session::closeAll()
 {
   Model_Application::getApplication()->deleteAllDocuments();
-  static const Events_ID aDocChangeEvent = Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED);
+  static const Events_ID aDocsCloseEvent = Events_Loop::eventByName(EVENT_DOCUMENTS_CLOSED);
   myCurrentDoc = NULL;
-  static std::shared_ptr<Events_Message> aMsg(new Events_Message(aDocChangeEvent));
+  static std::shared_ptr<Events_Message> aMsg(new Events_Message(aDocsCloseEvent));
   Events_Loop::loop()->send(aMsg);
-  Events_Loop::loop()->flush(aDocChangeEvent);
+  Events_Loop::loop()->flush(aDocsCloseEvent);
 }
 
 void Model_Session::startOperation(const std::string& theId, const bool theAttachedToNested)
@@ -687,4 +687,4 @@ Handle(TDocStd_Application) Model_Session::application()
 {
   return Model_Application::getApplication();
 }
-#endif
\ No newline at end of file
+#endif
index 20d90f09cd551802a603c90e0b1e3c44ebd8da4a..98ea6d896540a9b038e72fb79f135acd3afff2d5 100644 (file)
@@ -60,6 +60,8 @@ MAYBE_UNUSED static const char * EVENT_OBJECT_TO_REDISPLAY = "ObjectsToRedisplay
 MAYBE_UNUSED static const char * EVENT_PLUGIN_LOADED = "PluginLoaded";
 /// The active document becomes another one
 MAYBE_UNUSED static const char * EVENT_DOCUMENT_CHANGED = "CurrentDocumentChanged";
+/// All documents closed
+MAYBE_UNUSED static const char * EVENT_DOCUMENTS_CLOSED = "AllDocumentsClosed";
 
 /// Event ID that order of objects in group is changed,
 /// so, tree must be fully recreated (movement of feature)
index 8528d7687c194bef7acefa30a8199dfedcd7d4c1..eb8cf55898e2dcd9c587995dedc32b5e03e74232 100644 (file)
@@ -188,6 +188,7 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
 
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENTS_CLOSED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_LICENSE_VALID));
 
@@ -1674,7 +1675,9 @@ if (aObjIndex.isValid()) { \
 //******************************************************
 void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMessage)
 {
-  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) {
+  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENTS_CLOSED)) {
+    closeDocument();
+  } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) {
     SessionPtr aMgr = ModelAPI_Session::get();
     if (!aMgr->hasModuleDocument()) // if document is closed, do not call the document creation
       return;