Followup c9251c, fix crash

This commit is contained in:
Nyall Dawson 2016-10-20 17:32:06 +10:00
parent 3bdc77d3da
commit bc30cdf41d
3 changed files with 6 additions and 6 deletions

View File

@ -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()

View File

@ -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 );

View File

@ -159,17 +159,17 @@ 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();
}
@ -177,7 +177,7 @@ QSize QgsSymbolLegendNode::minimumIconSize( QgsRenderContext& context ) const
{
minSz = QgsImageOperation::nonTransparentImageRect(
QgsSymbolLayerUtils::symbolPreviewPixmap( mItem.symbol(), QSize( minSz.width(), 512 ),
&context ).toImage(),
context ).toImage(),
minSz,
true ).size();
}