Skip to content
Permalink
Browse files

Fix leaks in raster engine

  • Loading branch information
nyalldawson committed Aug 26, 2015
1 parent c9a0055 commit bea3d7200a0515ca067fe96d586fc80dec877b76
@@ -276,18 +276,22 @@ void QgsContrastEnhancement::setContrastEnhancementAlgorithm( ContrastEnhancemen
switch ( theAlgorithm )
{
case StretchToMinimumMaximum :
delete mContrastEnhancementFunction;
mContrastEnhancementFunction = new QgsLinearMinMaxEnhancement( mRasterDataType, mMinimumValue, mMaximumValue );
break;
case StretchAndClipToMinimumMaximum :
delete mContrastEnhancementFunction;
mContrastEnhancementFunction = new QgsLinearMinMaxEnhancementWithClip( mRasterDataType, mMinimumValue, mMaximumValue );
break;
case ClipToMinimumMaximum :
delete mContrastEnhancementFunction;
mContrastEnhancementFunction = new QgsClipToMinMaxEnhancement( mRasterDataType, mMinimumValue, mMaximumValue );
break;
case UserDefinedEnhancement :
//Do nothing
break;
default:
delete mContrastEnhancementFunction;
mContrastEnhancementFunction = new QgsContrastEnhancementFunction( mRasterDataType, mMinimumValue, mMaximumValue );
break;
}
@@ -313,6 +317,7 @@ void QgsContrastEnhancement::setContrastEnhancementFunction( QgsContrastEnhancem

if ( 0 != theFunction )
{
delete mContrastEnhancementFunction;
mContrastEnhancementFunction = theFunction;
mContrastEnhancementAlgorithm = UserDefinedEnhancement;
generateLookupTable();
@@ -928,15 +928,18 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh

if ( rendererType == "singlebandgray" )
{
if ( myEnhancements.value( 0 ) ) myGrayRenderer->setContrastEnhancement( myEnhancements.value( 0 ) );
if ( myEnhancements.first() ) myGrayRenderer->setContrastEnhancement( myEnhancements.takeFirst( ) );
}
else if ( rendererType == "multibandcolor" )
{
if ( myEnhancements.value( 0 ) ) myMultiBandRenderer->setRedContrastEnhancement( myEnhancements.value( 0 ) );
if ( myEnhancements.value( 1 ) ) myMultiBandRenderer->setGreenContrastEnhancement( myEnhancements.value( 1 ) );
if ( myEnhancements.value( 2 ) ) myMultiBandRenderer->setBlueContrastEnhancement( myEnhancements.value( 2 ) );
if ( myEnhancements.first() ) myMultiBandRenderer->setRedContrastEnhancement( myEnhancements.takeFirst() );
if ( myEnhancements.first() ) myMultiBandRenderer->setGreenContrastEnhancement( myEnhancements.takeFirst() );
if ( myEnhancements.first() ) myMultiBandRenderer->setBlueContrastEnhancement( myEnhancements.takeFirst() );
}

//delete all remaining unused enhancements
qDeleteAll( myEnhancements );

emit repaintRequested();
}

@@ -38,6 +38,7 @@ QgsRasterRenderer::QgsRasterRenderer( QgsRasterInterface* input, const QString&

QgsRasterRenderer::~QgsRasterRenderer()
{
delete mRasterTransparency;
}

int QgsRasterRenderer::bandCount() const

0 comments on commit bea3d72

Please sign in to comment.
You can’t perform that action at this time.