Skip to content

Commit b558c08

Browse files
committed
Fixing null pointer on ramp bug
1 parent 25a7be2 commit b558c08

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,15 +1301,18 @@ void QgsGraduatedSymbolRendererV2::updateColorRamp( QgsVectorColorRampV2 *ramp,
13011301
this->setInvertedColorRamp( inverted );
13021302
}
13031303

1304-
foreach ( QgsRendererRangeV2 range, mRanges )
1304+
if( mSourceColorRamp )
13051305
{
1306-
QgsSymbolV2* symbol = range.symbol()->clone();
1307-
double colorValue;
1308-
if ( inverted ) colorValue = ( mRanges.count() > 1 ? ( double )( mRanges.count() - i - 1 ) / ( mRanges.count() - 1 ) : 0 );
1309-
else colorValue = ( mRanges.count() > 1 ? ( double ) i / ( mRanges.count() - 1 ) : 0 );
1310-
symbol->setColor( mSourceColorRamp->color( colorValue ) );
1311-
updateRangeSymbol( i, symbol );
1312-
++i;
1306+
foreach ( QgsRendererRangeV2 range, mRanges )
1307+
{
1308+
QgsSymbolV2* symbol = range.symbol()->clone();
1309+
double colorValue;
1310+
if ( inverted ) colorValue = ( mRanges.count() > 1 ? ( double )( mRanges.count() - i - 1 ) / ( mRanges.count() - 1 ) : 0 );
1311+
else colorValue = ( mRanges.count() > 1 ? ( double ) i / ( mRanges.count() - 1 ) : 0 );
1312+
symbol->setColor( mSourceColorRamp->color( colorValue ) );
1313+
updateRangeSymbol( i, symbol );
1314+
++i;
1315+
}
13131316
}
13141317

13151318
}

src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()
581581

582582
mRenderer->setClassAttribute(attrName);
583583
mRenderer->setMode(mode);
584+
mRenderer->setSourceColorRamp(ramp->clone());
584585
bool updateUiCount=true;
585586
QApplication::setOverrideCursor( Qt::WaitCursor );
586587
mRenderer->updateClasses(mLayer,mode,nclasses);

0 commit comments

Comments
 (0)