Skip to content

Commit

Permalink
Fix LayerTreeModel use of beginInsertRows with embedded legends
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Santilli committed Dec 23, 2014
1 parent a4aaff5 commit 32079ed
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/layertree/qgslayertreemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,9 @@ void QgsLayerTreeModel::addLegendToLayer( QgsLayerTreeLayer* nodeL )

QList<QgsLayerTreeModelLegendNode*> filteredLstNew = filterLegendNodes( lstNew );

beginInsertRows( node2index( nodeL ), 0, filteredLstNew.count() - 1 );
bool isEmbedded = filteredLstNew.count() == 1 && filteredLstNew[0]->isEmbeddedInParent();

if ( ! isEmbedded ) beginInsertRows( node2index( nodeL ), 0, filteredLstNew.count() - 1 );

foreach ( QgsLayerTreeModelLegendNode* n, lstNew )
{
Expand All @@ -805,7 +807,7 @@ void QgsLayerTreeModel::addLegendToLayer( QgsLayerTreeLayer* nodeL )
mOriginalLegendNodes[nodeL] = lstNew;
mLegendNodes[nodeL] = filteredLstNew;

endInsertRows();
if ( ! isEmbedded ) endInsertRows();
}


Expand Down

0 comments on commit 32079ed

Please sign in to comment.