Skip to content

Commit

Permalink
Fix memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 29, 2015
1 parent 39f4ed5 commit e5fb5a6
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions src/plugins/topology/topolTest.cpp
Expand Up @@ -416,21 +416,21 @@ ErrorList topolTest::checkDuplicates( double tolerance, QgsVectorLayer *layer1,

QList<FeatureLayer> fls;
fls << *it << *it;
QgsGeometry* conflict = new QgsGeometry( *g1 );
QScopedPointer<QgsGeometry> conflict( new QgsGeometry( *g1 ) );

if ( isExtent )
{
if ( canvasExtentPoly->disjoint( conflict ) )
if ( canvasExtentPoly->disjoint( conflict.data() ) )
{
continue;
}
if ( canvasExtentPoly->crosses( conflict ) )
if ( canvasExtentPoly->crosses( conflict.data() ) )
{
conflict = conflict->intersection( canvasExtentPoly );
conflict.reset( conflict->intersection( canvasExtentPoly ) );
}
}

TopolErrorDuplicates* err = new TopolErrorDuplicates( bb, conflict, fls );
TopolErrorDuplicates* err = new TopolErrorDuplicates( bb, conflict.take(), fls );

errorList << err;
}
Expand Down Expand Up @@ -543,21 +543,21 @@ ErrorList topolTest::checkOverlaps( double tolerance, QgsVectorLayer *layer1, Qg
{
QList<FeatureLayer> fls;
fls << *it << *it;
QgsGeometry* conflictGeom = g1->intersection( g2 );
QScopedPointer< QgsGeometry > conflictGeom( g1->intersection( g2 ) );

if ( isExtent )
{
if ( canvasExtentPoly->disjoint( conflictGeom ) )
if ( canvasExtentPoly->disjoint( conflictGeom.data() ) )
{
continue;
}
if ( canvasExtentPoly->crosses( conflictGeom ) )
if ( canvasExtentPoly->crosses( conflictGeom.data() ) )
{
conflictGeom = conflictGeom->intersection( canvasExtentPoly );
conflictGeom.reset( conflictGeom->intersection( canvasExtentPoly ) );
}
}

TopolErrorOverlaps* err = new TopolErrorOverlaps( bb, conflictGeom, fls );
TopolErrorOverlaps* err = new TopolErrorOverlaps( bb, conflictGeom.take(), fls );

errorList << err;
}
Expand Down Expand Up @@ -637,6 +637,7 @@ ErrorList topolTest::checkGaps( double tolerance, QgsVectorLayer *layer1, QgsVec
QgsGeometry* polyGeom = QgsGeometry::fromPolygon( polygon );

geomList.push_back( GEOSGeom_clone_r( geosctxt, polyGeom->asGeos() ) );
delete polyGeom;
}

}
Expand Down Expand Up @@ -954,6 +955,7 @@ ErrorList topolTest::checkPointCoveredBySegment( double tolerance, QgsVectorLaye
{
if ( canvasExtentPoly->disjoint( conflictGeom ) )
{
delete conflictGeom;
continue;
}
}
Expand Down Expand Up @@ -1178,7 +1180,7 @@ ErrorList topolTest::checkOverlapWithLayer( double tolerance, QgsVectorLayer* la
QgsRectangle r2 = g2->boundingBox();
r.combineExtentWith( &r2 );

QgsGeometry* conflictGeom = g1->intersection( g2 );
QScopedPointer<QgsGeometry> conflictGeom( g1->intersection( g2 ) );
// could this for some reason return NULL?
if ( !conflictGeom )
{
Expand All @@ -1187,13 +1189,13 @@ ErrorList topolTest::checkOverlapWithLayer( double tolerance, QgsVectorLayer* la

if ( isExtent )
{
if ( canvasExtentPoly->disjoint( conflictGeom ) )
if ( canvasExtentPoly->disjoint( conflictGeom.data() ) )
{
continue;
}
if ( canvasExtentPoly->crosses( conflictGeom ) )
if ( canvasExtentPoly->crosses( conflictGeom.data() ) )
{
conflictGeom = conflictGeom->intersection( canvasExtentPoly );
conflictGeom.reset( conflictGeom->intersection( canvasExtentPoly ) );
}
}

Expand All @@ -1204,7 +1206,7 @@ ErrorList topolTest::checkOverlapWithLayer( double tolerance, QgsVectorLayer* la
fl.feature = f;
fl.layer = layer2;
fls << *it << fl;
TopolErrorIntersection* err = new TopolErrorIntersection( r, conflictGeom, fls );
TopolErrorIntersection* err = new TopolErrorIntersection( r, conflictGeom.take(), fls );

errorList << err;
}
Expand Down Expand Up @@ -1279,6 +1281,7 @@ ErrorList topolTest::checkPointCoveredByLineEnds( double tolerance, QgsVectorLay
{
if ( canvasExtentPoly->disjoint( conflictGeom ) )
{
delete conflictGeom;
continue;
}
}
Expand Down Expand Up @@ -1372,25 +1375,24 @@ ErrorList topolTest::checkyLineEndsCoveredByPoints( double tolerance, QgsVectorL

if ( !touched )
{
QgsGeometry* conflictGeom = new QgsGeometry( *g1 );
QScopedPointer<QgsGeometry> conflictGeom( new QgsGeometry( *g1 ) );

if ( isExtent )
{
if ( canvasExtentPoly->disjoint( conflictGeom ) )
if ( canvasExtentPoly->disjoint( conflictGeom.data() ) )
{
continue;
}
if ( canvasExtentPoly->crosses( conflictGeom ) )
if ( canvasExtentPoly->crosses( conflictGeom.data() ) )
{
conflictGeom = conflictGeom->intersection( canvasExtentPoly );
conflictGeom.reset( conflictGeom->intersection( canvasExtentPoly ) );
}
}
QList<FeatureLayer> fls;
fls << *it << *it;
//bb.scale(10);


TopolErrorLineEndsNotCoveredByPoints* err = new TopolErrorLineEndsNotCoveredByPoints( bb, conflictGeom, fls );
TopolErrorLineEndsNotCoveredByPoints* err = new TopolErrorLineEndsNotCoveredByPoints( bb, conflictGeom.take(), fls );
errorList << err;
}
}
Expand Down Expand Up @@ -1456,6 +1458,7 @@ ErrorList topolTest::checkPointInPolygon( double tolerance, QgsVectorLayer *laye
{
if ( canvasExtentPoly->disjoint( conflictGeom ) )
{
delete conflictGeom;
continue;
}
}
Expand Down

0 comments on commit e5fb5a6

Please sign in to comment.