Skip to content

Commit

Permalink
Merge pull request #3250 from rldhont/qgsmaplayerregistry_check_layer…
Browse files Browse the repository at this point in the history
…s_before_removed

[BUGFIX] QgsMapLayerRegistry: Check layers before removed
  • Loading branch information
rldhont committed Jul 4, 2016
2 parents 5d4836e + 5daa546 commit 2bbd201
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/core/qgsmaplayerregistry.cpp
Expand Up @@ -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 );
Expand Down

0 comments on commit 2bbd201

Please sign in to comment.