Skip to content

Commit

Permalink
Followup c9251c, fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 20, 2016
1 parent 3bdc77d commit bc30cdf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion python/core/layertree/qgslayertreemodellegendnode.sip
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/core/layertree/qgslayertreemodel.cpp
Expand Up @@ -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 );
Expand Down
8 changes: 4 additions & 4 deletions src/core/layertree/qgslayertreemodellegendnode.cpp
Expand Up @@ -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();
}
Expand Down

0 comments on commit bc30cdf

Please sign in to comment.