Skip to content
Permalink
Browse files

Fix bad alloc when styling raster with random color ramp (fix #13112)

(cherry-picked from 688ac16)
  • Loading branch information
nyalldawson committed Aug 4, 2015
1 parent 3bcc2bc commit 55022226da7beba3439357b8573fe6ab2d64dcc4
@@ -374,7 +374,7 @@ QgsRandomColorsV2::~QgsRandomColorsV2()

int QgsRandomColorsV2::count() const
{
return INT_MAX;
return -1;
}

double QgsRandomColorsV2::value( int index ) const
@@ -28,10 +28,12 @@ class CORE_EXPORT QgsVectorColorRampV2

virtual ~QgsVectorColorRampV2() {}

// Number of defined colors
/** Returns number of defined colors, or -1 if undefined
*/
virtual int count() const = 0;

// Relative value (0,1) of color at index
/** Returns relative value between [0,1] of color at specified index
*/
virtual double value( int index ) const = 0;

virtual QColor color( double value ) const = 0;
@@ -350,6 +350,17 @@ void QgsSingleBandPseudoColorRendererWidget::on_mColorRampComboBox_currentIndexC
Q_UNUSED( index );
QSettings settings;
settings.setValue( "/Raster/defaultPalette", mColorRampComboBox->currentText() );

QgsVectorColorRampV2* ramp = mColorRampComboBox->currentColorRamp();
if ( !ramp )
return;

bool enableContinuous = ( ramp->count() > 0 );
mClassificationModeComboBox->setEnabled( enableContinuous );
if ( !enableContinuous )
{
mClassificationModeComboBox->setCurrentIndex( mClassificationModeComboBox->findData( EqualInterval ) );
}
}

void QgsSingleBandPseudoColorRendererWidget::populateColormapTreeWidget( const QList<QgsColorRampShader::ColorRampItem>& colorRampItems )

0 comments on commit 5502222

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