Skip to content

Commit

Permalink
[BUGFIX] QgsMapLayerRegistry: Check layers before removed
Browse files Browse the repository at this point in the history
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
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -131,21 +131,23 @@ void QgsMapLayerRegistry::removeMapLayers( const QList<QgsMapLayer*>& layers )
return; return;


QStringList layerIds; QStringList layerIds;
QList<QgsMapLayer*> layerList;


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


emit layersWillBeRemoved( layerIds ); 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() ); QString myId( lyr->id() );
emit layerWillBeRemoved( myId ); emit layerWillBeRemoved( myId );
emit layerWillBeRemoved( lyr ); emit layerWillBeRemoved( lyr );
Expand Down

0 comments on commit 5daa546

Please sign in to comment.