From ba9dc8b33b685e6aceeef4632f430e15208e7714 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 25 May 2015 17:37:56 +0300 Subject: [PATCH] Issue #552: Clear variables on document close --- src/Model/Model_Session.cpp | 2 +- src/PartSet/PartSet_DataTreeModel.h | 4 ++++ src/PartSet/PartSet_DocumentDataModel.cpp | 5 ++++- src/XGUI/XGUI_Workshop.cpp | 1 - 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index de3cddb28..d5a79927c 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -49,7 +49,7 @@ bool Model_Session::save(const char* theFileName, std::list& theRes void Model_Session::closeAll() { Model_Application::getApplication()->deleteAllDocuments(); - ROOT_DOC->close(true); + //ROOT_DOC->close(true); } void Model_Session::startOperation(const std::string& theId) diff --git a/src/PartSet/PartSet_DataTreeModel.h b/src/PartSet/PartSet_DataTreeModel.h index ff96baf9b..0e45f4555 100644 --- a/src/PartSet/PartSet_DataTreeModel.h +++ b/src/PartSet/PartSet_DataTreeModel.h @@ -74,6 +74,10 @@ class PartSet_PartModel : public PartSet_FeaturesModel : PartSet_FeaturesModel(theParent) { } + ~PartSet_PartModel() + { + myPart = FeaturePtr(); + } /// Set part id /// \param theId a new id diff --git a/src/PartSet/PartSet_DocumentDataModel.cpp b/src/PartSet/PartSet_DocumentDataModel.cpp index c4f245821..bf0eff521 100644 --- a/src/PartSet/PartSet_DocumentDataModel.cpp +++ b/src/PartSet/PartSet_DocumentDataModel.cpp @@ -483,6 +483,7 @@ void PartSet_DocumentDataModel::clearSubModels() foreach (PartSet_PartModel* aPart, myPartModels) delete aPart; myPartModels.clear(); + myActivePartModel = 0; } ObjectPtr PartSet_DocumentDataModel::object(const QModelIndex& theIndex) const @@ -546,8 +547,10 @@ void PartSet_DocumentDataModel::removeSubModel(PartSet_PartModel* theModel) myIndexes.removeAt(aId); aToRemove.removeLast(); } - delete theModel; + if (theModel == myActivePartModel) + myActivePartModel = 0; myPartModels.removeAll(theModel); + delete theModel; } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index df417b4d9..dcf348ff6 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1582,7 +1582,6 @@ void XGUI_Workshop::closeDocument() SessionPtr aMgr = ModelAPI_Session::get(); aMgr->closeAll(); - objectBrowser()->clearContent(); } //************************************************************** -- 2.39.2