# HG changeset patch # User Chris Cannam # Date 1168012150 0 # Node ID 41c4916575872be02196f30881cd12abe9d5ee54 # Parent 0d2fb43b5ee568aaee0e67200842885caef0aec0 * 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 diff -r 0d2fb43b5ee5 -r 41c491657587 document/Document.cpp --- 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 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 diff -r 0d2fb43b5ee5 -r 41c491657587 document/SVFileReader.cpp --- a/document/SVFileReader.cpp Fri Jan 05 14:46:45 2007 +0000 +++ b/document/SVFileReader.cpp Fri Jan 05 15:49:10 2007 +0000 @@ -791,7 +791,22 @@ } if (!m_inData && m_currentPane) { + + QString visible = attributes.value("visible"); + bool dormant = (visible == "false"); + + // We need to do this both before and after adding the layer + // to the view -- we need it to be dormant if appropriate + // before it's actually added to the view so that any property + // box gets the right state when it's added, but the add layer + // command sets dormant to false because it assumes it may be + // restoring a previously dormant layer, so we need to set it + // again afterwards too. Hm + layer->setLayerDormant(m_currentPane, dormant); + m_document->addLayerToView(m_currentPane, layer); + + layer->setLayerDormant(m_currentPane, dormant); } return true; diff -r 0d2fb43b5ee5 -r 41c491657587 main/MainWindow.cpp --- a/main/MainWindow.cpp Fri Jan 05 14:46:45 2007 +0000 +++ b/main/MainWindow.cpp Fri Jan 05 15:49:10 2007 +0000 @@ -2873,7 +2873,7 @@ QApplication::restoreOverrideCursor(); - if (bzFile.errorString() != "") { + if (!bzFile.isOK()) { QMessageBox::critical(this, tr("Failed to write file"), tr("Failed to write to file \"%1\": %2") .arg(path).arg(bzFile.errorString()));