Skip to content
Permalink
Browse files

Fix potential crash when removing entities from a style

  • Loading branch information
nyalldawson committed Jan 14, 2019
1 parent d5cedfe commit 4b154a4a88f1d9e60f5b30aa835d7f18ff5d8635
Showing with 19 additions and 13 deletions.
  1. +19 −13 src/core/symbology/qgsstylemodel.cpp
@@ -124,15 +124,18 @@ QVariant QgsStyleModel::data( const QModelIndex &index, int role ) const
return icon;

std::unique_ptr< QgsSymbol > symbol( mStyle->symbol( name ) );
if ( mAdditionalSizes.isEmpty() )
icon.addPixmap( QgsSymbolLayerUtils::symbolPreviewPixmap( symbol.get(), QSize( 24, 24 ), 1 ) );

for ( const QVariant &size : mAdditionalSizes )
if ( symbol )
{
QSize s = size.toSize();
icon.addPixmap( QgsSymbolLayerUtils::symbolPreviewPixmap( symbol.get(), s, static_cast< int >( s.width() * ICON_PADDING_FACTOR ) ) );
}
if ( mAdditionalSizes.isEmpty() )
icon.addPixmap( QgsSymbolLayerUtils::symbolPreviewPixmap( symbol.get(), QSize( 24, 24 ), 1 ) );

for ( const QVariant &size : mAdditionalSizes )
{
QSize s = size.toSize();
icon.addPixmap( QgsSymbolLayerUtils::symbolPreviewPixmap( symbol.get(), s, static_cast< int >( s.width() * ICON_PADDING_FACTOR ) ) );
}

}
mSymbolIconCache.insert( name, icon );
return icon;
}
@@ -144,14 +147,17 @@ QVariant QgsStyleModel::data( const QModelIndex &index, int role ) const
return icon;

std::unique_ptr< QgsColorRamp > ramp( mStyle->colorRamp( name ) );
if ( mAdditionalSizes.isEmpty() )
icon.addPixmap( QgsSymbolLayerUtils::colorRampPreviewPixmap( ramp.get(), QSize( 24, 24 ), 1 ) );
for ( const QVariant &size : mAdditionalSizes )
if ( ramp )
{
QSize s = size.toSize();
icon.addPixmap( QgsSymbolLayerUtils::colorRampPreviewPixmap( ramp.get(), s, static_cast< int >( s.width() * ICON_PADDING_FACTOR ) ) );
}
if ( mAdditionalSizes.isEmpty() )
icon.addPixmap( QgsSymbolLayerUtils::colorRampPreviewPixmap( ramp.get(), QSize( 24, 24 ), 1 ) );
for ( const QVariant &size : mAdditionalSizes )
{
QSize s = size.toSize();
icon.addPixmap( QgsSymbolLayerUtils::colorRampPreviewPixmap( ramp.get(), s, static_cast< int >( s.width() * ICON_PADDING_FACTOR ) ) );
}

}
mColorRampIconCache.insert( name, icon );
return icon;
}

0 comments on commit 4b154a4

Please sign in to comment.
You can’t perform that action at this time.