Salome HOME
Small fix of ImportNaming.
[modules/shaper.git] / src / Model / Model_Application.cpp
index 147bb4ac29e2c4450b28c73bafa042215c8c8c18..204cafe1418d99d1e690eb87fe5b6242cc46003a 100644 (file)
@@ -85,6 +85,26 @@ bool Model_Application::isLoadByDemand(std::string theID)
   return myLoadedByDemand.find(theID) != myLoadedByDemand.end();
 }
 
+//=======================================================================
+void Model_Application::removeUselessDocuments(
+  std::list<std::shared_ptr<ModelAPI_Document> > theUsedDocs)
+{
+  std::map<std::string, std::shared_ptr<Model_Document> >::iterator aDoc = myDocs.begin();
+  while(aDoc != myDocs.end()) {
+    bool aFound = false;
+    std::list<std::shared_ptr<ModelAPI_Document> >::iterator aUsed = theUsedDocs.begin();
+    for(; !aFound && aUsed != theUsedDocs.end(); aUsed++) {
+      aFound = aDoc->second == *aUsed;
+    }
+    if (!aFound) { // remove the useless
+      aDoc->second->close();
+      aDoc = myDocs.erase(aDoc);
+    } else {
+      aDoc++;
+    }
+  }
+}
+
 //=======================================================================
 Model_Application::Model_Application()
 {