Skip to content
Permalink
Browse files

legend interface: guard layer dereferences (fixes #13899)

  • Loading branch information
jef-n committed Nov 29, 2015
1 parent c14352f commit 3b2d7173f66ee260021a262167f571eb7ff72788
Showing with 22 additions and 4 deletions.
  1. +22 −4 src/app/legend/qgsapplegendinterface.cpp
@@ -75,8 +75,11 @@ void QgsAppLegendInterface::removeGroup( int groupIndex )
parentGroup->removeChildNode( group );
}

void QgsAppLegendInterface::moveLayer( QgsMapLayer * ml, int groupIndex )
void QgsAppLegendInterface::moveLayer( QgsMapLayer *ml, int groupIndex )
{
if ( !ml )
return;

QgsLayerTreeGroup* group = groupIndexToNode( groupIndex );
if ( !group )
return;
@@ -155,14 +158,20 @@ int QgsAppLegendInterface::groupNodeToIndex( QgsLayerTreeGroup* group )
return _groupNodeToIndex( group, mLayerTreeView->layerTreeModel()->rootGroup(), currentIndex );
}

void QgsAppLegendInterface::setLayerVisible( QgsMapLayer * ml, bool visible )
void QgsAppLegendInterface::setLayerVisible( QgsMapLayer *ml, bool visible )
{
if ( !ml )
return;

if ( QgsLayerTreeLayer* nodeLayer = mLayerTreeView->layerTreeModel()->rootGroup()->findLayer( ml->id() ) )
nodeLayer->setVisible( visible ? Qt::Checked : Qt::Unchecked );
}

void QgsAppLegendInterface::setLayerExpanded( QgsMapLayer * ml, bool expand )
{
if ( !ml )
return;

if ( QgsLayerTreeLayer* nodeLayer = mLayerTreeView->layerTreeModel()->rootGroup()->findLayer( ml->id() ) )
setExpanded( nodeLayer, expand );
}
@@ -247,17 +256,23 @@ bool QgsAppLegendInterface::isGroupVisible( int groupIndex )
return false;
}

bool QgsAppLegendInterface::isLayerExpanded( QgsMapLayer * ml )
bool QgsAppLegendInterface::isLayerExpanded( QgsMapLayer *ml )
{
if ( !ml )
return false;

if ( QgsLayerTreeLayer* nodeLayer = mLayerTreeView->layerTreeModel()->rootGroup()->findLayer( ml->id() ) )
return nodeLayer->isExpanded();

return false;
}


bool QgsAppLegendInterface::isLayerVisible( QgsMapLayer * ml )
bool QgsAppLegendInterface::isLayerVisible( QgsMapLayer *ml )
{
if ( !ml )
return false;

if ( QgsLayerTreeLayer* nodeLayer = mLayerTreeView->layerTreeModel()->rootGroup()->findLayer( ml->id() ) )
return nodeLayer->isVisible() == Qt::Checked;

@@ -283,6 +298,9 @@ QList< QgsMapLayer * > QgsAppLegendInterface::layers() const

void QgsAppLegendInterface::refreshLayerSymbology( QgsMapLayer *ml )
{
if ( !ml )
return;

mLayerTreeView->refreshLayerSymbology( ml->id() );
}

0 comments on commit 3b2d717

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