Skip to content
Permalink
Browse files
Followup c9251c, fix crash
  • Loading branch information
nyalldawson committed Oct 20, 2016
1 parent 3bdc77d commit bc30cdf41d2698e7404a24c39d793f2a7b735981
@@ -156,7 +156,7 @@ class QgsSymbolLegendNode : QgsLayerTreeModelLegendNode
* render context in advance and call this method instead of minimumIconSize().
* @note added in QGIS 2.18
*/
QSize minimumIconSize( QgsRenderContext &context ) const;
QSize minimumIconSize( QgsRenderContext* context ) const;

/** Returns the symbol used by the legend node.
* @see setSymbol()
@@ -1497,7 +1497,7 @@ void QgsLayerTreeModel::invalidateLegendMapBasedData()
QgsSymbolLegendNode* n = dynamic_cast<QgsSymbolLegendNode*>( legendNode );
if ( n )
{
const QSize sz( n->minimumIconSize( *context ) );
const QSize sz( n->minimumIconSize( context.data() ) );
const QString parentKey( n->data( QgsLayerTreeModelLegendNode::ParentRuleKeyRole ).toString() );
widthMax[parentKey] = qMax( sz.width(), widthMax.contains( parentKey ) ? widthMax[parentKey] : 0 );
n->setIconSize( sz );
@@ -159,25 +159,25 @@ Qt::ItemFlags QgsSymbolLegendNode::flags() const
QSize QgsSymbolLegendNode::minimumIconSize() const
{
QScopedPointer<QgsRenderContext> context( createTemporaryRenderContext() );
return minimumIconSize( *context );
return minimumIconSize( context.data() );
}

QSize QgsSymbolLegendNode::minimumIconSize( QgsRenderContext& context ) const
QSize QgsSymbolLegendNode::minimumIconSize( QgsRenderContext* context ) const
{
QSize minSz( 16, 16 );
if ( mItem.symbol() && mItem.symbol()->type() == QgsSymbol::Marker )
{
minSz = QgsImageOperation::nonTransparentImageRect(
QgsSymbolLayerUtils::symbolPreviewPixmap( mItem.symbol(), QSize( 512, 512 ),
&context ).toImage(),
context ).toImage(),
minSz,
true ).size();
}
else if ( mItem.symbol() && mItem.symbol()->type() == QgsSymbol::Line )
{
minSz = QgsImageOperation::nonTransparentImageRect(
QgsSymbolLayerUtils::symbolPreviewPixmap( mItem.symbol(), QSize( minSz.width(), 512 ),
&context ).toImage(),
context ).toImage(),
minSz,
true ).size();
}

0 comments on commit bc30cdf

Please sign in to comment.