Skip to content

Commit

Permalink
Fix leaks in raster engine
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 26, 2015
1 parent c9a0055 commit bea3d72
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/core/raster/qgscontrastenhancement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -313,6 +317,7 @@ void QgsContrastEnhancement::setContrastEnhancementFunction( QgsContrastEnhancem

if ( 0 != theFunction )
{
delete mContrastEnhancementFunction;
mContrastEnhancementFunction = theFunction;
mContrastEnhancementAlgorithm = UserDefinedEnhancement;
generateLookupTable();
Expand Down
11 changes: 7 additions & 4 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions src/core/raster/qgsrasterrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ QgsRasterRenderer::QgsRasterRenderer( QgsRasterInterface* input, const QString&

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

int QgsRasterRenderer::bandCount() const
Expand Down

0 comments on commit bea3d72

Please sign in to comment.