Skip to content

Commit 3d2747c

Browse files
committedOct 12, 2014
Fix crash when choosing a null field for categorized style
1 parent f30452d commit 3d2747c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
static QColor _interpolate( QColor c1, QColor c2, double value )
3232
{
33+
if ( isnan( value ) ) value = 1;
3334
int r = ( int )( c1.red() + value * ( c2.red() - c1.red() ) );
3435
int g = ( int )( c1.green() + value * ( c2.green() - c1.green() ) );
3536
int b = ( int )( c1.blue() + value * ( c2.blue() - c1.blue() ) );
@@ -365,11 +366,10 @@ double QgsRandomColorsV2::value( int index ) const
365366

366367
QColor QgsRandomColorsV2::color( double value ) const
367368
{
368-
Q_UNUSED( value );
369369
int minVal = 130;
370370
int maxVal = 255;
371371

372-
int colorIndex = value * ( mTotalColorCount - 1 );
372+
int colorIndex = !isnan( value ) ? value : 1 * ( mTotalColorCount - 1 );
373373
if ( mTotalColorCount >= 1 && mPrecalculatedColors.length() > colorIndex )
374374
{
375375
//use precalculated hue

0 commit comments

Comments
 (0)
Please sign in to comment.