File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ void QgsMapLayerRegistry::removeMapLayers( const QStringList& theLayerIds )
119
119
QList<QgsMapLayer*> layers;
120
120
Q_FOREACH ( const QString &myId, theLayerIds )
121
121
{
122
- layers << mMapLayers [ myId] ;
122
+ layers << mMapLayers . value ( myId ) ;
123
123
}
124
124
125
125
removeMapLayers ( layers );
@@ -160,12 +160,13 @@ void QgsMapLayerRegistry::removeMapLayers( const QList<QgsMapLayer*>& layers )
160
160
161
161
void QgsMapLayerRegistry::removeMapLayer ( const QString& theLayerId )
162
162
{
163
- removeMapLayers ( QList<QgsMapLayer*>() << mMapLayers [ theLayerId] );
163
+ removeMapLayers ( QList<QgsMapLayer*>() << mMapLayers . value ( theLayerId ) );
164
164
}
165
165
166
166
void QgsMapLayerRegistry::removeMapLayer ( QgsMapLayer* layer )
167
167
{
168
- removeMapLayers ( QList<QgsMapLayer*>() << layer );
168
+ if ( layer )
169
+ removeMapLayers ( QList<QgsMapLayer*>() << layer );
169
170
}
170
171
171
172
void QgsMapLayerRegistry::removeAllMapLayers ()
Original file line number Diff line number Diff line change @@ -25,6 +25,11 @@ def test_RemoveLayerShouldNotSegFault(self):
25
25
reg = QgsMapLayerRegistry .instance ()
26
26
# Should not segfault
27
27
reg .removeMapLayers (['not_exists' ])
28
+ reg .removeMapLayer ('not_exists2' )
29
+
30
+ # check also that the removal of an unexistant layer does not insert a null layer
31
+ for k , layer in reg .mapLayers ().items ():
32
+ assert (layer is not None )
28
33
29
34
30
35
if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments