Skip to content

Commit 4dbc0bc

Browse files
author
jef
committedNov 20, 2007
add only valid layers, fixes #812
git-svn-id: http://svn.osgeo.org/qgis/trunk@7624 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 1213e34 commit 4dbc0bc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/core/qgsmaplayerregistry.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ QgsMapLayer *
7777
QgsMapLayerRegistry::addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal )
7878
{
7979
QgsDebugMsg("QgsMapLayerRegistry::addMaplayer - '" + theMapLayer->name());
80+
if( !theMapLayer->isValid() ) {
81+
QgsDebugMsg("cannot add invalid layers");
82+
return 0;
83+
}
84+
8085
//check the layer is not already registered!
8186
std::map<QString,QgsMapLayer*>::iterator myIterator = mMapLayers.find(theMapLayer->getLayerID());
8287
//if myIterator returns mMapLayers.end() then it does not exist in registry and its safe to add it
@@ -92,7 +97,7 @@ QgsMapLayer *
9297
else
9398
{
9499
QgsDebugMsg("addMaplayer - " + theMapLayer->name() + " already registered");
95-
return 0x0;
100+
return 0;
96101
}
97102
} // QgsMapLayerRegistry::addMapLayer
98103

0 commit comments

Comments
 (0)
Please sign in to comment.