Skip to content

Commit ed20ff3

Browse files
committedOct 31, 2011
Fix #4439
1 parent dd03451 commit ed20ff3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

‎src/app/legend/qgslegend.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,12 @@ void QgsLegend::refreshLayerSymbology( QString key, bool expandItem )
17521752
}
17531753

17541754
//store the current item
1755-
QModelIndex currentItemIndex( currentIndex() );
1755+
QTreeWidgetItem* current = currentItem();
1756+
// in case the current item is a child of the layer, use the layer as current item
1757+
// because otherwise we would set an invalid item as current item
1758+
// (in refreshSymbology the symbology items are removed and new ones are added)
1759+
if ( current->parent() == theLegendLayer )
1760+
current = current->parent();
17561761

17571762
double widthScale = 1.0;
17581763
if ( mMapCanvas && mMapCanvas->map() )
@@ -1763,7 +1768,7 @@ void QgsLegend::refreshLayerSymbology( QString key, bool expandItem )
17631768
theLegendLayer->refreshSymbology( key, widthScale );
17641769

17651770
//restore the current item again
1766-
setCurrentIndex( currentItemIndex );
1771+
setCurrentItem( current );
17671772
adjustIconSize();
17681773
setItemExpanded( theLegendLayer, expandItem );//make sure the symbology items are visible
17691774
}

0 commit comments

Comments
 (0)
Please sign in to comment.