Fixing null pointer on ramp bug

This commit is contained in:
Chris Crook 2014-09-26 18:12:41 +12:00
parent 25a7be2966
commit b558c08bd4
2 changed files with 12 additions and 8 deletions

View File

@ -1301,15 +1301,18 @@ void QgsGraduatedSymbolRendererV2::updateColorRamp( QgsVectorColorRampV2 *ramp,
this->setInvertedColorRamp( inverted );
}
foreach ( QgsRendererRangeV2 range, mRanges )
if( mSourceColorRamp )
{
QgsSymbolV2* symbol = range.symbol()->clone();
double colorValue;
if ( inverted ) colorValue = ( mRanges.count() > 1 ? ( double )( mRanges.count() - i - 1 ) / ( mRanges.count() - 1 ) : 0 );
else colorValue = ( mRanges.count() > 1 ? ( double ) i / ( mRanges.count() - 1 ) : 0 );
symbol->setColor( mSourceColorRamp->color( colorValue ) );
updateRangeSymbol( i, symbol );
++i;
foreach ( QgsRendererRangeV2 range, mRanges )
{
QgsSymbolV2* symbol = range.symbol()->clone();
double colorValue;
if ( inverted ) colorValue = ( mRanges.count() > 1 ? ( double )( mRanges.count() - i - 1 ) / ( mRanges.count() - 1 ) : 0 );
else colorValue = ( mRanges.count() > 1 ? ( double ) i / ( mRanges.count() - 1 ) : 0 );
symbol->setColor( mSourceColorRamp->color( colorValue ) );
updateRangeSymbol( i, symbol );
++i;
}
}
}

View File

@ -581,6 +581,7 @@ void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()
mRenderer->setClassAttribute(attrName);
mRenderer->setMode(mode);
mRenderer->setSourceColorRamp(ramp->clone());
bool updateUiCount=true;
QApplication::setOverrideCursor( Qt::WaitCursor );
mRenderer->updateClasses(mLayer,mode,nclasses);