Skip to content

Commit

Permalink
Fix a crash when trying to removeMapLayer a null pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Mercier committed Dec 3, 2015
1 parent 3755c3b commit 984d1f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/core/qgsmaplayerregistry.cpp
Expand Up @@ -131,14 +131,18 @@ void QgsMapLayerRegistry::removeMapLayers( const QList<QgsMapLayer*>& layers )

Q_FOREACH ( QgsMapLayer* layer, layers )
{
layerIds << layer->id();
if ( layer )
layerIds << layer->id();
}

emit layersWillBeRemoved( layerIds );
emit layersWillBeRemoved( layers );

Q_FOREACH ( QgsMapLayer* lyr, layers )
{
if ( !lyr )
continue;

QString myId( lyr->id() );
if ( mOwnedLayers.contains( lyr ) )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsmaplayerregistry.h
Expand Up @@ -129,7 +129,7 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
* The layers being removed are deleted as well as the registry
* table entries.
*
* @param layers The layers to remove
* @param layers The layers to remove. Null pointers are ignored
*
* @note As a side-effect QgsProject is made dirty.
*/
Expand Down Expand Up @@ -159,7 +159,7 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
* The layer being removed is deleted as well as the registry
* table entry.
*
* @param layer The layer to remove
* @param layer The layer to remove. Nothing happens if the pointer is null
*
* @note As a side-effect QgsProject is made dirty.
*/
Expand Down

0 comments on commit 984d1f2

Please sign in to comment.