Skip to content

Commit

Permalink
add only valid layers, fixes #812
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@7624 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 20, 2007
1 parent 1213e34 commit 4dbc0bc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/qgsmaplayerregistry.cpp
Expand Up @@ -77,6 +77,11 @@ QgsMapLayer *
QgsMapLayerRegistry::addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal )
{
QgsDebugMsg("QgsMapLayerRegistry::addMaplayer - '" + theMapLayer->name());
if( !theMapLayer->isValid() ) {
QgsDebugMsg("cannot add invalid layers");
return 0;
}

//check the layer is not already registered!
std::map<QString,QgsMapLayer*>::iterator myIterator = mMapLayers.find(theMapLayer->getLayerID());
//if myIterator returns mMapLayers.end() then it does not exist in registry and its safe to add it
Expand All @@ -92,7 +97,7 @@ QgsMapLayer *
else
{
QgsDebugMsg("addMaplayer - " + theMapLayer->name() + " already registered");
return 0x0;
return 0;
}
} // QgsMapLayerRegistry::addMapLayer

Expand Down

0 comments on commit 4dbc0bc

Please sign in to comment.