From 20325f200780bedcaf75c7dea891f5c22daf9b4e Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 1 Dec 2016 14:21:16 +0300 Subject: [PATCH] Issue #1900 Fatal error when close study --- src/XGUI/XGUI_DataModel.cpp | 5 ++++- src/XGUI/XGUI_DataModel.h | 5 +++++ src/XGUI/XGUI_Workshop.cpp | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 6e0acaba8..1a4efa787 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -62,7 +62,8 @@ ModelAPI_Document* getSubDocument(void* theObj) // Constructor ************************************************* -XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParent) +XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParent), + myIsEventsProcessingStopped(false) { Events_Loop* aLoop = Events_Loop::loop(); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); @@ -79,6 +80,8 @@ XGUI_DataModel::~XGUI_DataModel() //****************************************************** void XGUI_DataModel::processEvent(const std::shared_ptr& theMessage) { + if (myIsEventsProcessingStopped) + return; DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); std::string aRootType = myXMLReader->rootType(); std::string aSubType = myXMLReader->subType(); diff --git a/src/XGUI/XGUI_DataModel.h b/src/XGUI/XGUI_DataModel.h index a57f85c20..f3dc27c13 100644 --- a/src/XGUI/XGUI_DataModel.h +++ b/src/XGUI/XGUI_DataModel.h @@ -125,6 +125,9 @@ public: /// Initialises XML data model reader. It must be initialised before DataModel using. void setXMLReader(Config_DataModelReader* theReader) { myXMLReader = theReader; } + /// Do not processing anymore events of model loop + void stopEventsProcessing() { myIsEventsProcessingStopped = true; } + signals: /// Signal about tree had been rebuilt void treeRebuilt(); @@ -161,6 +164,8 @@ private: QStringList listOfShowNotEmptyFolders(bool fromRoot = true) const; Config_DataModelReader* myXMLReader; + + bool myIsEventsProcessingStopped; }; #endif \ No newline at end of file diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 6996a2d02..8b7aa83a5 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #ifndef HAVE_SALOME #include @@ -2029,6 +2030,10 @@ void XGUI_Workshop::closeDocument() module()->closeDocument(); + // data model need not process the document's signals about objects modifications as + // the document is closed + objectBrowser()->dataModel()->stopEventsProcessing(); + SessionPtr aMgr = ModelAPI_Session::get(); aMgr->closeAll(); } -- 2.39.2