Skip to content

Commit a8ad5c1

Browse files
committedAug 4, 2015
Fix bad alloc when styling raster with random color ramp (fix #13112)
(cherry-picked from 688ac16)
1 parent 1874c37 commit a8ad5c1

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed
 

‎src/core/symbology-ng/qgsvectorcolorrampv2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ QgsRandomColorsV2::~QgsRandomColorsV2()
372372

373373
int QgsRandomColorsV2::count() const
374374
{
375-
return INT_MAX;
375+
return -1;
376376
}
377377

378378
double QgsRandomColorsV2::value( int index ) const

‎src/core/symbology-ng/qgsvectorcolorrampv2.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ class CORE_EXPORT QgsVectorColorRampV2
2828

2929
virtual ~QgsVectorColorRampV2() {}
3030

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

34-
// Relative value (0,1) of color at index
35+
/** Returns relative value between [0,1] of color at specified index
36+
*/
3537
virtual double value( int index ) const = 0;
3638

3739
virtual QColor color( double value ) const = 0;

‎src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,17 @@ void QgsSingleBandPseudoColorRendererWidget::on_mColorRampComboBox_currentIndexC
350350
Q_UNUSED( index );
351351
QSettings settings;
352352
settings.setValue( "/Raster/defaultPalette", mColorRampComboBox->currentText() );
353+
354+
QgsVectorColorRampV2* ramp = mColorRampComboBox->currentColorRamp();
355+
if ( !ramp )
356+
return;
357+
358+
bool enableContinuous = ( ramp->count() > 0 );
359+
mClassificationModeComboBox->setEnabled( enableContinuous );
360+
if ( !enableContinuous )
361+
{
362+
mClassificationModeComboBox->setCurrentIndex( mClassificationModeComboBox->findData( EqualInterval ) );
363+
}
353364
}
354365

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

0 commit comments

Comments
 (0)
Please sign in to comment.