Skip to content
Permalink
Browse files

Fix for ticket 549: groups lost and all layers expanded, if layers mi…

…ssing opening the project

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6457 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Jan 26, 2007
1 parent c3736d3 commit eb03f9a9e0ccc1f30a1325f41c5b67477aea03b4
Showing with 14 additions and 8 deletions.
  1. +13 −7 src/app/legend/qgslegend.cpp
  2. +1 −1 src/core/qgsproject.cpp
@@ -1038,7 +1038,7 @@ bool QgsLegend::readXML(QDomNode& legendnode)
if(childelem.tagName()=="legendgroup")
{
QgsLegendGroup* theGroup = new QgsLegendGroup(this, name);
childelem.attribute("open") == "true" ? expandItem(theGroup) : collapseItem(theGroup);
childelem.attribute("open") == "true" ? expanded.push_back(theGroup) : collapsed.push_back(theGroup);
//set the checkbox of the legend group to the right state
blockSignals(true);
QString checked = childelem.attribute("checked");
@@ -1103,8 +1103,15 @@ bool QgsLegend::readXML(QDomNode& legendnode)
//find out the legendlayer
std::map<QString,QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
std::map<QString, QgsMapLayer*>::const_iterator iter = mapLayers.find(childelem.attribute("layerid"));

if(iter != mapLayers.end() && lastLayerFileGroup)
if(iter == mapLayers.end()) //the layer cannot be found (e.g. the file has been moved)
{
//remove the whole legendlayer if this is the only legendlayerfile
if(childelem.previousSibling().isNull() && childelem.nextSibling().isNull())
{
delete lastLayer;
}
}
else if(lastLayerFileGroup)
{
QgsMapLayer* theMapLayer = iter->second;
QgsLegendLayerFile* theLegendLayerFile = new QgsLegendLayerFile(lastLayerFileGroup, QgsLegendLayerFile::nameFromLayer(theMapLayer), theMapLayer);
@@ -1135,7 +1142,7 @@ bool QgsLegend::readXML(QDomNode& legendnode)

theLegendLayerFile->updateLegendItem();
refreshLayerSymbology(theMapLayer->getLayerID());
}
}
}
else if(childelem.tagName()=="filegroup")
{
@@ -1155,11 +1162,10 @@ bool QgsLegend::readXML(QDomNode& legendnode)
}

// Do the tree item expands and collapses.
for (int i = 0; i < collapsed.size(); ++i)
collapseItem(collapsed[i]);

for (int i = 0; i < expanded.size(); ++i)
expandItem(expanded[i]);
for (int i = 0; i < collapsed.size(); ++i)
collapseItem(collapsed[i]);

return true;
}
@@ -858,7 +858,7 @@ bool QgsProject::read()
// Since we could be executing this from the test harness which
// doesn't *have* layers -- nor a GUI for that matter -- we'll just
// leave in the whining and boldly stomp on.

emit readProject(*doc);
throw QgsProjectBadLayerException( getMapLayersResults.second );

// return false;

0 comments on commit eb03f9a

Please sign in to comment.
You can’t perform that action at this time.