Skip to content
Permalink
Browse files

fix QgsLayerTreeModel::refreshLayerLegend (#9785)

* fix QgsLayerTreeModel::refreshLayerLegend

Guard if the QModelIndex (idx) has no children.

* Update qgslayertreemodel.cpp

* Update qgslayertreemodel.cpp

* Update qgslayertreemodel.cpp

* Apply suggestions from code review

Co-Authored-By: vcloarec <vcloarec@gmail.com>
  • Loading branch information
vcloarec authored and m-kuhn committed Apr 16, 2019
1 parent 891ea18 commit bed3da43083002c561cf9b5aaebaca85681caa78
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/core/layertree/qgslayertreemodel.cpp
@@ -539,9 +539,12 @@ void QgsLayerTreeModel::refreshLayerLegend( QgsLayerTreeLayer *nodeLayer )

// update children
int oldNodeCount = rowCount( idx );
beginRemoveRows( idx, 0, std::max( oldNodeCount - 1, 0 ) );
removeLegendFromLayer( nodeLayer );
endRemoveRows();
if ( oldNodeCount > 0 )
{
beginRemoveRows( idx, 0, oldNodeCount - 1 );
removeLegendFromLayer( nodeLayer );
endRemoveRows();
}

addLegendToLayer( nodeLayer );
int newNodeCount = rowCount( idx );

0 comments on commit bed3da4

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