From: vsv Date: Thu, 11 Oct 2018 13:30:02 +0000 (+0300) Subject: Avoid crash on clearing of a document by a script X-Git-Tag: V9_2_0a2~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d2d54415aa7bc73156a11016dbc79e0ca592ce6a;p=modules%2Fshaper.git Avoid crash on clearing of a document by a script --- diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 2a830e788..a22db3780 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -72,6 +72,10 @@ bool Model_Session::save(const char* theFileName, std::list& theRes void Model_Session::closeAll() { Model_Application::getApplication()->deleteAllDocuments(); + static const Events_ID aDocChangeEvent = Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED); + static std::shared_ptr 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) diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index dc328a5f6..ffdab1522 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -46,6 +46,7 @@ #include #include #include +#include //-------------------------------------------------------------------------------------- #include //-------------------------------------------------------------------------------------- @@ -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"; diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 51b970981..aa7b4e383 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1442,9 +1442,12 @@ void PartSet_Module::processEvent(const std::shared_ptr& 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; diff --git a/src/PartSet/PartSet_TreeNodes.cpp b/src/PartSet/PartSet_TreeNodes.cpp index a4381a3f7..92d25db69 100644 --- a/src/PartSet/PartSet_TreeNodes.cpp +++ b/src/PartSet/PartSet_TreeNodes.cpp @@ -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();