Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[BUGFIX] QgsMapLayerRegistry: Check layers before removed
Probably fixed #15088 Segmentation fault when using layersRemoved SIGNAL
  • Loading branch information
rldhont committed Jun 29, 2016
1 parent 009fbc6 commit 5daa546
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/core/qgsmaplayerregistry.cpp
Expand Up @@ -131,21 +131,23 @@ 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;
}
}

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 5daa546

Please sign in to comment.