Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leaks fixes #772

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ SET(QGIS_CORE_HDRS
raster/qgsrastershader.h
raster/qgsrastershaderfunction.h
raster/qgsrasterviewport.h
raster/qgsbrightnesscontrastfilter.h
raster/qgshuesaturationfilter.h
raster/qgsrasternuller.h
raster/qgsrasterrenderer.h

symbology-ng/qgscategorizedsymbolrendererv2.h
symbology-ng/qgscolorbrewerpalette.h
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsrendercontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ QgsRenderContext::QgsRenderContext()

QgsRenderContext::~QgsRenderContext()
{
delete mCoordTransform;
}

void QgsRenderContext::setCoordinateTransform( const QgsCoordinateTransform* t )
Expand Down
13 changes: 2 additions & 11 deletions src/core/raster/qgsmultibandcolorrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,7 @@ QgsRasterBlock* QgsMultiBandColorRenderer::block( int bandNo, QgsRectangle cons

if ( !outputBlock->reset( QGis::ARGB32_Premultiplied, width, height ) )
{
for ( int i = 0; i < bandBlocks.size(); i++ )
{
delete bandBlocks.value( i );
}
qDeleteAll(bandBlocks);
return outputBlock;
}

Expand Down Expand Up @@ -309,13 +306,7 @@ QgsRasterBlock* QgsMultiBandColorRenderer::block( int bandNo, QgsRectangle cons
}
}

//delete input blocks
QMap<int, QgsRasterBlock*>::const_iterator bandDelIt = bandBlocks.constBegin();
for ( ; bandDelIt != bandBlocks.constEnd(); ++bandDelIt )
{
delete bandDelIt.value();
}

qDeleteAll(bandBlocks);
return outputBlock;
}

Expand Down
4 changes: 3 additions & 1 deletion src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ void QgsCategorizedSymbolRendererV2::startRender( QgsRenderContext& context, con
( mSizeScaleFieldIdx != -1 ? QgsSymbolV2::DataDefinedSizeScale : 0 ) );
tempSymbol->startRender( context, vlayer );
mTempSymbols[ it->value().toString()] = tempSymbol;
delete tempSymbol;
}
}

Expand All @@ -395,8 +396,9 @@ void QgsCategorizedSymbolRendererV2::stopRender( QgsRenderContext& context )
for ( ; it2 != mTempSymbols.end(); ++it2 )
{
it2.value()->stopRender( context );
delete it2.value();
}

qDeleteAll(mTempSymbols);
mTempSymbols.clear();
}

Expand Down
6 changes: 1 addition & 5 deletions src/core/symbology-ng/qgssymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ void QgsSymbolLayerV2::removeDataDefinedProperty( const QString& property )

void QgsSymbolLayerV2::removeDataDefinedProperties()
{
QMap< QString, QgsExpression* >::iterator it = mDataDefinedProperties.begin();
for ( ; it != mDataDefinedProperties.constEnd(); ++it )
{
delete( it.value() );
}
qDeleteAll(mDataDefinedProperties);
mDataDefinedProperties.clear();
}

Expand Down
15 changes: 6 additions & 9 deletions src/core/symbology-ng/qgssymbollayerv2utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2438,7 +2438,7 @@ QgsSymbolV2Map QgsSymbolLayerV2Utils::loadSymbols( QDomElement& element )
if ( parts.count() < 3 )
{
QgsDebugMsg( "found subsymbol with invalid name: " + it.key() );
delete it.value(); // we must delete it
delete *it; // we must delete it
continue; // some invalid syntax
}
QString symname = parts[1];
Expand All @@ -2447,15 +2447,15 @@ QgsSymbolV2Map QgsSymbolLayerV2Utils::loadSymbols( QDomElement& element )
if ( !symbols.contains( symname ) )
{
QgsDebugMsg( "subsymbol references invalid symbol: " + symname );
delete it.value(); // we must delete it
delete *it; // we must delete it
continue;
}

QgsSymbolV2* sym = symbols[symname];
if ( symlayer < 0 || symlayer >= sym->symbolLayerCount() )
{
QgsDebugMsg( "subsymbol references invalid symbol layer: " + QString::number( symlayer ) );
delete it.value(); // we must delete it
delete *it; // we must delete it
continue;
}

Expand Down Expand Up @@ -2492,10 +2492,7 @@ QDomElement QgsSymbolLayerV2Utils::saveSymbols( QgsSymbolV2Map& symbols, QString

void QgsSymbolLayerV2Utils::clearSymbolMap( QgsSymbolV2Map& symbols )
{
foreach ( QString name, symbols.keys() )
{
delete symbols.value( name );
}
qDeleteAll(symbols);
symbols.clear();
}

Expand Down Expand Up @@ -2557,7 +2554,7 @@ double QgsSymbolLayerV2Utils::lineWidthScaleFactor( const QgsRenderContext& c, Q
else //QgsSymbol::MapUnit
{
double mup = c.mapToPixel().mapUnitsPerPixel();
if ( mup > 0 )
if ( mup >= 1 )
{
return 1.0 / mup;
}
Expand All @@ -2577,7 +2574,7 @@ double QgsSymbolLayerV2Utils::pixelSizeScaleFactor( const QgsRenderContext& c, Q
else //QgsSymbol::MapUnit
{
double mup = c.mapToPixel().mapUnitsPerPixel();
if ( mup > 0 )
if ( mup >= 1 )
{
return c.rasterScaleFactor() / c.mapToPixel().mapUnitsPerPixel();
}
Expand Down