]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Avoid crash on clearing of a document by a script
authorvsv <vsv@opencascade.com>
Thu, 11 Oct 2018 13:30:02 +0000 (16:30 +0300)
committervsv <vsv@opencascade.com>
Thu, 11 Oct 2018 13:30:02 +0000 (16:30 +0300)
src/Model/Model_Session.cpp
src/ModelHighAPI/ModelHighAPI_Tools.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_TreeNodes.cpp

index 2a830e788a740f3414a5ad29d9de423470f07db3..a22db3780ba50741c258ef66f0e94007c4118420 100644 (file)
@@ -72,6 +72,10 @@ 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 std::shared_ptr<Events_Message> aMsg(new Events_Message(aDocChangeEvent));
+  Events_Loop::loop()->send(aMsg);
+  Events_Loop::loop()->flush(aDocChangeEvent);
 }
 
 void Model_Session::startOperation(const std::string& theId, const bool theAttachedToNested)
index dc328a5f614252a8981fc4d9f028738cff6e26c7..ffdab15225c33898e756327f385a0401c7d900ea 100644 (file)
@@ -46,6 +46,7 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_ResultPart.h>
+#include <ModelAPI_Events.h>
 //--------------------------------------------------------------------------------------
 #include <Config_ModuleReader.h>
 //--------------------------------------------------------------------------------------
@@ -490,7 +491,6 @@ static bool checkDump(SessionPtr theSession,
   // close all before importation of the script
   theSession->closeAll();
 
-
   // execute the dumped
   PyGILState_STATE gstate = PyGILState_Ensure(); /* acquire python thread */
   static char aReadMode[] = "r";
index 51b970981757e15022b4828fe4fedd498a726930..aa7b4e383f47e0d4298d138e4c26fb6407b0a877 100755 (executable)
@@ -1442,9 +1442,12 @@ void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMess
 
     SessionPtr aMgr = ModelAPI_Session::get();
     DocumentPtr aActiveDoc = aMgr->activeDocument();
-    // workaround for #2431 (SISGSEGV when launching some unit tests from GUI)
-    //if (myActivePartIndex.isValid())
-    //  aTreeView->setExpanded(myActivePartIndex, false);
+
+    // Clear active part index if there is no Part documents
+    // It could be not null if document was closed and opened a new
+    // without closeDocument call
+    if (aMgr->allOpenedDocuments().size() <= 1)
+      myActivePartIndex = QModelIndex();
 
     XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
     QModelIndex aOldActive = myActivePartIndex;
index a4381a3f7109fea49c47afccc1b31a7cef192b2d..92d25db69152fea370540718a10e4e6f84b308b3 100644 (file)
@@ -948,7 +948,7 @@ QVariant PartSet_PartRootNode::data(int theColumn, int theRole) const
 Qt::ItemFlags PartSet_PartRootNode::flags(int theColumn) const
 {
   if (myObject->isDisabled())
-    return (theColumn == 2) ? Qt::ItemIsSelectable : aNullFlag;
+    return (theColumn == 2) ? Qt::ItemIsSelectable : aDefaultFlag;
 
   SessionPtr aSession = ModelAPI_Session::get();
   DocumentPtr aActiveDoc = aSession->activeDocument();