File tree 1 file changed +8
-6
lines changed
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -131,21 +131,23 @@ void QgsMapLayerRegistry::removeMapLayers( const QList<QgsMapLayer*>& layers )
131
131
return ;
132
132
133
133
QStringList layerIds;
134
+ QList<QgsMapLayer*> layerList;
134
135
135
136
Q_FOREACH ( QgsMapLayer* layer, layers )
136
137
{
137
- if ( layer )
138
+ // check layer and the registry contains it
139
+ if ( layer && mMapLayers .contains ( layer->id () ) )
140
+ {
138
141
layerIds << layer->id ();
142
+ layerList << layer;
143
+ }
139
144
}
140
145
141
146
emit layersWillBeRemoved ( layerIds );
142
- emit layersWillBeRemoved ( layers );
147
+ emit layersWillBeRemoved ( layerList );
143
148
144
- Q_FOREACH ( QgsMapLayer* lyr, layers )
149
+ Q_FOREACH ( QgsMapLayer* lyr, layerList )
145
150
{
146
- if ( !lyr )
147
- continue ;
148
-
149
151
QString myId ( lyr->id () );
150
152
emit layerWillBeRemoved ( myId );
151
153
emit layerWillBeRemoved ( lyr );
You can’t perform that action at this time.
0 commit comments