Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #2534 from mhugo/fix_nullp
Browse files Browse the repository at this point in the history
Fix a crash when trying to removeMapLayer a null pointer
  • Loading branch information
elpaso committed Dec 4, 2015
2 parents ab3542a + 984d1f2 commit 7829497
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 7829497

Please sign in to comment.