Skip to content
Permalink
Browse files

[BUGFIX] QgsMapLayerRegistry: Check layers before removed

Probably fixed #15088 Segmentation fault when using layersRemoved SIGNAL
  • Loading branch information
rldhont committed Jun 23, 2016
1 parent ef35faf commit cd35952138e70126623d7a5161252e2517bc780d
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/core/qgsmaplayerregistry.cpp
@@ -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 );

0 comments on commit cd35952

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