@@ -1311,34 +1311,33 @@ void QgsLayerTreeModel::legendInvalidateMapBasedData()
1311
1311
// we do that here because for symbols with size defined in map units
1312
1312
// the symbol sizes changes depends on the zoom level
1313
1313
1314
- QList<QgsSymbolV2LegendNode*> symbolNodes;
1315
- QMap<QString, int > widthMax;
1316
1314
foreach ( const LayerLegendData& data, mLegend )
1317
1315
{
1316
+ QList<QgsSymbolV2LegendNode*> symbolNodes;
1317
+ QMap<QString, int > widthMax;
1318
1318
foreach ( QgsLayerTreeModelLegendNode* legendNode, data.originalNodes )
1319
1319
{
1320
- legendNode->invalidateMapBasedData ();
1321
1320
QgsSymbolV2LegendNode* n = dynamic_cast <QgsSymbolV2LegendNode*>( legendNode );
1322
1321
if ( n )
1323
1322
{
1324
- n->setParent ( this ); // map scale are in the model, so the parent needs to be set
1325
1323
const QSize sz ( n->minimumIconSize () );
1326
1324
const QString parentKey ( n->data ( QgsLayerTreeModelLegendNode::ParentRuleKeyRole ).toString () );
1327
1325
widthMax[parentKey] = qMax ( sz.width (), widthMax.contains ( parentKey ) ? widthMax[parentKey] : 0 );
1328
1326
n->setIconSize ( sz );
1329
1327
symbolNodes.append ( n );
1330
1328
}
1331
1329
}
1330
+ foreach ( QgsSymbolV2LegendNode* n, symbolNodes )
1331
+ {
1332
+ const QString parentKey ( n->data ( QgsLayerTreeModelLegendNode::ParentRuleKeyRole ).toString () );
1333
+ Q_ASSERT ( widthMax[parentKey] > 0 );
1334
+ const int twiceMarginWidth = 2 ; // a one pixel margin avoids hugly rendering of icon
1335
+ n->setIconSize ( QSize ( widthMax[parentKey] + twiceMarginWidth, n->iconSize ().rheight () + twiceMarginWidth ) );
1336
+ }
1337
+ foreach ( QgsLayerTreeModelLegendNode* legendNode, data.originalNodes )
1338
+ legendNode->invalidateMapBasedData ();
1332
1339
}
1333
1340
1334
- foreach ( QgsSymbolV2LegendNode* n, symbolNodes )
1335
- {
1336
- const QString parentKey ( n->data ( QgsLayerTreeModelLegendNode::ParentRuleKeyRole ).toString () );
1337
- Q_ASSERT ( widthMax[parentKey] > 0 );
1338
- const int twiceMarginWidth = 2 ; // a one pixel margin avoids hugly rendering of icon
1339
- n->setIconSize ( QSize ( widthMax[parentKey] + twiceMarginWidth, n->iconSize ().rheight () + twiceMarginWidth ) );
1340
- n->invalidateMapBasedData ();
1341
- }
1342
1341
}
1343
1342
1344
1343
// Legend nodes routines - end
0 commit comments