File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,11 @@ QgsMapLayer *
77
77
QgsMapLayerRegistry::addMapLayer ( QgsMapLayer * theMapLayer, bool theEmitSignal )
78
78
{
79
79
QgsDebugMsg (" QgsMapLayerRegistry::addMaplayer - '" + theMapLayer->name ());
80
+ if ( !theMapLayer->isValid () ) {
81
+ QgsDebugMsg (" cannot add invalid layers" );
82
+ return 0 ;
83
+ }
84
+
80
85
// check the layer is not already registered!
81
86
std::map<QString,QgsMapLayer*>::iterator myIterator = mMapLayers .find (theMapLayer->getLayerID ());
82
87
// if myIterator returns mMapLayers.end() then it does not exist in registry and its safe to add it
@@ -92,7 +97,7 @@ QgsMapLayer *
92
97
else
93
98
{
94
99
QgsDebugMsg (" addMaplayer - " + theMapLayer->name () + " already registered" );
95
- return 0x0 ;
100
+ return 0 ;
96
101
}
97
102
} // QgsMapLayerRegistry::addMapLayer
98
103
You can’t perform that action at this time.
0 commit comments