Skip to content

Commit

Permalink
Fixing null pointer on ramp bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrook committed Sep 26, 2014
1 parent 25a7be2 commit b558c08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
Expand Up @@ -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;
}
}

}
Expand Down
Expand Up @@ -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);
Expand Down

0 comments on commit b558c08

Please sign in to comment.