Inverted polygons: fix memory leaks

This commit is contained in:
Hugo Mercier 2014-06-16 09:34:26 +02:00
parent b2782ee7a1
commit 71a1f89e8d
2 changed files with 16 additions and 6 deletions

View File

@ -6402,16 +6402,18 @@ namespace QgsGeometryAlgorithms
QgsGeometry* unaryUnion( const QList<QgsGeometry*>& geometryList )
{
QList<GEOSGeometry*> geoms;
QVector<GEOSGeometry*> geoms;
foreach( QgsGeometry* g, geometryList )
{
// const cast: it is ok here, since the pointers will only be used to be stored
// in a list for a call to union
geoms.append( const_cast<GEOSGeometry*>(g->asGeos()) );
geoms.append( GEOSGeom_clone(g->asGeos()) );
}
GEOSGeometry* unioned = _makeUnion( geoms );
GEOSGeometry* geomCollection = 0;
geomCollection = createGeosCollection( GEOS_GEOMETRYCOLLECTION, geoms );
GEOSGeometry* geomUnion = GEOSUnaryUnion( geomCollection );
GEOSGeom_destroy( geomCollection );
QgsGeometry *ret = new QgsGeometry();
ret->fromGeos( unioned );
ret->fromGeos( geomUnion );
return ret;
}

View File

@ -73,6 +73,7 @@ void QgsInvertedPolygonRenderer::startRender( QgsRenderContext& context, const Q
mSubRenderer->startRender( context, fields );
mFeaturesCategories.clear();
mSymbolCategories.clear();
mFeatureDecorations.clear();
mFields = fields;
@ -279,6 +280,13 @@ void QgsInvertedPolygonRenderer::stopRender( QgsRenderContext& context )
}
mSubRenderer->renderFeature( feat, mContext );
}
for ( FeatureCategoryVector::iterator cit = mFeaturesCategories.begin(); cit != mFeaturesCategories.end(); ++cit )
{
foreach( QgsGeometry* g, cit->geometries )
{
delete g;
}
}
// when no features are visible, we still have to draw the exterior rectangle
// warning: when sub renderers have more than one possible symbols,