Skip to content

Commit

Permalink
use QgsMapLayer::isSpatial()
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jan 22, 2018
1 parent 86024ef commit 123470b
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions src/core/layertree/qgslayertree.cpp
Expand Up @@ -62,15 +62,11 @@ void QgsLayerTree::setCustomLayerOrder( const QStringList &customLayerOrder )
{
// configuration from 2.x projects might have non spatial layers
QgsMapLayer *layer = nodeLayer->layer();
if ( layer->type() == QgsMapLayer::VectorLayer )
if ( !layer || !layer->isSpatial() )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
if ( vl && !vl->isSpatial() )
{
continue;
}
continue;
}
layers.append( nodeLayer->layer() );
layers.append( layer );
}
}
setCustomLayerOrder( layers );
Expand All @@ -88,13 +84,9 @@ QList<QgsMapLayer *> QgsLayerTree::layerOrder() const
for ( const auto &treeLayer : findLayers() )
{
QgsMapLayer *layer = treeLayer->layer();
if ( layer && layer->type() == QgsMapLayer::VectorLayer )
if ( !layer || !layer->isSpatial() )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
if ( vl && !vl->isSpatial() )
{
continue;
}
continue;
}
layers.append( layer );
}
Expand Down Expand Up @@ -222,16 +214,9 @@ void QgsLayerTree::addMissingLayers()

for ( const auto layer : findLayers() )
{
if ( !mCustomLayerOrder.contains( layer->layer() ) && layer->layer() )
if ( !mCustomLayerOrder.contains( layer->layer() ) &&
layer->layer() && layer->layer()->isSpatial() )
{
if ( layer->layer()->type() == QgsMapLayer::VectorLayer )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer->layer() );
if ( vl && !vl->isSpatial() )
{
continue;
}
}
mCustomLayerOrder.append( layer->layer() );
changed = true;
}
Expand Down

0 comments on commit 123470b

Please sign in to comment.