Skip to content
Permalink
Browse files
Fix memory leaks
  • Loading branch information
nyalldawson committed May 29, 2015
1 parent 39f4ed5 commit e5fb5a6ad90b4656e66cf256be3345005c627400
Showing with 24 additions and 21 deletions.
  1. +24 −21 src/plugins/topology/topolTest.cpp
@@ -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;
}
@@ -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;
}
@@ -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;
}

}
@@ -954,6 +955,7 @@ ErrorList topolTest::checkPointCoveredBySegment( double tolerance, QgsVectorLaye
{
if ( canvasExtentPoly->disjoint( conflictGeom ) )
{
delete conflictGeom;
continue;
}
}
@@ -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 )
{
@@ -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 ) );
}
}

@@ -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;
}
@@ -1279,6 +1281,7 @@ ErrorList topolTest::checkPointCoveredByLineEnds( double tolerance, QgsVectorLay
{
if ( canvasExtentPoly->disjoint( conflictGeom ) )
{
delete conflictGeom;
continue;
}
}
@@ -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;
}
}
@@ -1456,6 +1458,7 @@ ErrorList topolTest::checkPointInPolygon( double tolerance, QgsVectorLayer *laye
{
if ( canvasExtentPoly->disjoint( conflictGeom ) )
{
delete conflictGeom;
continue;
}
}

0 comments on commit e5fb5a6

Please sign in to comment.