diff document/Document.cpp @ 84:41c491657587

* Further fix for restoring layer visibility from session file * Better handling of error state in bzip file device to avoid spurious errors * Fix #1495001 deleted layers prevail in saved session file
author Chris Cannam
date Fri, 05 Jan 2007 15:49:10 +0000
parents bedc7517b6e8
children 2678a1f132d2
line wrap: on
line diff
--- a/document/Document.cpp	Fri Jan 05 14:46:45 2007 +0000
+++ b/document/Document.cpp	Fri Jan 05 15:49:10 2007 +0000
@@ -747,12 +747,27 @@
 	m_mainModel->toXml(out, indent + "  ", "mainModel=\"true\"");
     }
 
+    // Models that are not used in a layer that is in a view should
+    // not be written.  Get our list of required models first.
+
+    std::set<const Model *> used;
+
+    for (LayerViewMap::const_iterator i = m_layerViewMap.begin();
+         i != m_layerViewMap.end(); ++i) {
+
+        if (i->first && !i->second.empty() && i->first->getModel()) {
+            used.insert(i->first->getModel());
+        }
+    }
+
     for (ModelMap::const_iterator i = m_models.begin();
 	 i != m_models.end(); ++i) {
 
         const Model *model = i->first;
 	const ModelRecord &rec = i->second;
 
+        if (used.find(model) == used.end()) continue;
+        
         // We need an intelligent way to determine which models need
         // to be streamed (i.e. have been edited, or are small) and
         // which should not be (i.e. remain as generated by a