Skip to content
Permalink
Browse files

Fix potential crash in color assistant, set a default ramp

  • Loading branch information
nyalldawson committed Feb 14, 2017
1 parent 599d985 commit 852b1dfb7953e573a67874472c2a76e2bb3f77b3
Showing with 15 additions and 1 deletion.
  1. +15 −1 src/gui/qgspropertyassistantwidget.cpp
@@ -416,15 +416,29 @@ QgsPropertyColorAssistantWidget::QgsPropertyColorAssistantWidget( QWidget* paren

bool supportsAlpha = definition.standardTemplate() == QgsPropertyDefinition::ColorWithAlpha;
mNullColorButton->setAllowAlpha( supportsAlpha );
mNullColorButton->setShowNoColor( true );
mNullColorButton->setColorDialogTitle( tr( "Color for null values" ) );
mNullColorButton->setContext( QStringLiteral( "symbology" ) );
mNullColorButton->setNoColorString( tr( "Transparent" ) );

if ( const QgsColorRampTransformer* colorTransform = dynamic_cast< const QgsColorRampTransformer* >( initialState.transformer() ) )
{
mNullColorButton->setColor( colorTransform->nullColor() );
mColorRampButton->setColorRamp( colorTransform->colorRamp() );
if ( colorTransform->colorRamp() )
mColorRampButton->setColorRamp( colorTransform->colorRamp() );
}

connect( mNullColorButton, &QgsColorButton::colorChanged, this, &QgsPropertyColorAssistantWidget::widgetChanged );
connect( mColorRampButton, &QgsColorRampButton::colorRampChanged, this, &QgsPropertyColorAssistantWidget::widgetChanged );

if ( !mColorRampButton->colorRamp() )
{
// set a default ramp
QString defaultRampName = QgsProject::instance()->readEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/ColorRamp" ), QString() );
std::unique_ptr< QgsColorRamp > defaultRamp( QgsStyle::defaultStyle()->colorRamp( !defaultRampName.isEmpty() ? defaultRampName : QStringLiteral( "Blues" ) ) );
if ( defaultRamp )
mColorRampButton->setColorRamp( defaultRamp.get() );
}
}

QgsColorRampTransformer* QgsPropertyColorAssistantWidget::createTransformer( double minValue, double maxValue ) const

0 comments on commit 852b1df

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