mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-12 00:02:25 -04:00
[BUGFIX] QgsMapLayerRegistry: Check layers before removed
Probably fixed #15088 Segmentation fault when using layersRemoved SIGNAL
This commit is contained in:
parent
009fbc6362
commit
5daa546f6f
@ -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 );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user