Skip to content
Permalink
Browse files

Fix #11703 and #11704

Do not create a layer node if the passed layer cannot be used (not in registry)
  • Loading branch information
wonder-sk committed Jan 13, 2015
1 parent 1614ac8 commit f28a6d1d7d426286f67b94b094a6653aec69f0a3
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/core/layertree/qgslayertreegroup.cpp
@@ -17,6 +17,8 @@

#include "qgslayertree.h"
#include "qgslayertreeutils.h"
#include "qgsmaplayer.h"
#include "qgsmaplayerregistry.h"

#include <QDomElement>
#include <QStringList>
@@ -57,13 +59,19 @@ QgsLayerTreeGroup* QgsLayerTreeGroup::addGroup( const QString &name )

QgsLayerTreeLayer*QgsLayerTreeGroup::insertLayer( int index, QgsMapLayer* layer )
{
if ( !layer || QgsMapLayerRegistry::instance()->mapLayer( layer->id() ) != layer )
return 0;

QgsLayerTreeLayer* ll = new QgsLayerTreeLayer( layer );
insertChildNode( index, ll );
return ll;
}

QgsLayerTreeLayer* QgsLayerTreeGroup::addLayer( QgsMapLayer* layer )
{
if ( !layer || QgsMapLayerRegistry::instance()->mapLayer( layer->id() ) != layer )
return 0;

QgsLayerTreeLayer* ll = new QgsLayerTreeLayer( layer );
addChildNode( ll );
return ll;

0 comments on commit f28a6d1

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