Salome HOME
Small fix of ImportNaming.
[modules/shaper.git] / src / Model / Model_Session.cpp
index 9430c7a16fce92d46ae8ac72f9cd2c08504e160d..159b7a2f678b19e60ac6fac4862c1881100dbeca 100644 (file)
@@ -53,6 +53,9 @@ void Model_Session::startOperation()
   static std::shared_ptr<Events_Message> aStartedMsg
     (new Events_Message(Events_Loop::eventByName("StartOperation")));
   Events_Loop::loop()->send(aStartedMsg);
+  // remove all useless documents that has been closed: on start of operation undo/redo is cleared
+  std::list<std::shared_ptr<ModelAPI_Document> > aUsedDocs = allOpenedDocuments();
+  Model_Application::getApplication()->removeUselessDocuments(aUsedDocs);
 }
 
 void Model_Session::finishOperation()
@@ -190,8 +193,9 @@ std::list<std::shared_ptr<ModelAPI_Document> > Model_Session::allOpenedDocuments
     DocumentPtr anAPIDoc = *aDoc;
     std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(anAPIDoc);
     if (aDoc) {
-      std::set<std::string>::const_iterator aSubIter = aDoc->subDocuments().cbegin();
-      for(; aSubIter != aDoc->subDocuments().cend(); aSubIter++) {
+      const std::set<std::string> aSubs = aDoc->subDocuments(true);
+      std::set<std::string>::const_iterator aSubIter = aSubs.cbegin();
+      for(; aSubIter != aSubs.cend(); aSubIter++) {
         if (!Model_Application::getApplication()->isLoadByDemand(*aSubIter)) {
           aResult.push_back(Model_Application::getApplication()->getDocument(*aSubIter));
         }