Skip to content
Permalink
Browse files

Merge pull request #3250 from rldhont/qgsmaplayerregistry_check_layer…

…s_before_removed

[BUGFIX] QgsMapLayerRegistry: Check layers before removed
  • Loading branch information
rldhont committed Jul 4, 2016
2 parents 5d4836e + 5daa546 commit 2bbd2018d2cdf0d8ccd5a2db5e0b3c77a112422b
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/core/qgsmaplayerregistry.cpp
@@ -123,24 +123,26 @@ void QgsMapLayerRegistry::removeMapLayers( const QList<QgsMapLayer*>& layers )
return;

QStringList layerIds;
QList<QgsMapLayer*> layerList;

Q_FOREACH ( QgsMapLayer* layer, layers )
{
if ( layer )
// check layer and the registry contains it
if ( layer && mMapLayers.contains( layer->id() ) )
{
layerIds << layer->id();
layerList << layer;
}
}

if ( layerIds.isEmpty() )
return;

emit layersWillBeRemoved( layerIds );
emit layersWillBeRemoved( layers );
emit layersWillBeRemoved( layerList );

Q_FOREACH ( QgsMapLayer* lyr, layers )
Q_FOREACH ( QgsMapLayer* lyr, layerList )
{
if ( !lyr )
continue;

QString myId( lyr->id() );
emit layerWillBeRemoved( myId );
emit layerWillBeRemoved( lyr );

0 comments on commit 2bbd201

Please sign in to comment.
You can’t perform that action at this time.