Skip to content
Permalink
Browse files

Fix memory leak in geometry snapper

  • Loading branch information
nyalldawson committed Feb 7, 2017
1 parent cb1849f commit c400326aadfd306eaefc247951fa7ad4d45ed13a
Showing with 8 additions and 8 deletions.
  1. +8 −8 src/analysis/vector/qgsgeometrysnapper.cpp
@@ -592,12 +592,12 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry& geometry, doubl
return QgsGeometry( subjGeom );

// SnapIndex for subject feature
QgsSnapIndex* subjSnapIndex = new QgsSnapIndex( center, 10 * snapTolerance );
std::unique_ptr< QgsSnapIndex > subjSnapIndex( new QgsSnapIndex( center, 10 * snapTolerance ) );
subjSnapIndex->addGeometry( subjGeom );

QgsAbstractGeometry* origSubjGeom = subjGeom->clone();
QgsSnapIndex* origSubjSnapIndex = new QgsSnapIndex( center, 10 * snapTolerance );
origSubjSnapIndex->addGeometry( origSubjGeom );
std::unique_ptr< QgsAbstractGeometry > origSubjGeom( subjGeom->clone() );
std::unique_ptr< QgsSnapIndex > origSubjSnapIndex( new QgsSnapIndex( center, 10 * snapTolerance ) );
origSubjSnapIndex->addGeometry( origSubjGeom.get() );

// Pass 2: add missing vertices to subject geometry
Q_FOREACH ( const QgsGeometry& refGeom, refGeometries )
@@ -638,17 +638,17 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry& geometry, doubl
const QgsSnapIndex::CoordIdx* idx = snapSegment->idxFrom;
subjGeom->insertVertex( QgsVertexId( idx->vidx.part, idx->vidx.ring, idx->vidx.vertex + 1 ), point );
subjPointFlags[idx->vidx.part][idx->vidx.ring].insert( idx->vidx.vertex + 1, SnappedToRefNode );
delete subjSnapIndex;
subjSnapIndex = new QgsSnapIndex( center, 10 * snapTolerance );
subjSnapIndex.reset( new QgsSnapIndex( center, 10 * snapTolerance ) );
subjSnapIndex->addGeometry( subjGeom );
}
}
}
}
}
}
delete subjSnapIndex;
delete origSubjSnapIndex;
subjSnapIndex.reset();
origSubjSnapIndex.reset();
origSubjGeom.reset();

// Pass 3: remove superfluous vertices: all vertices which are snapped to a segment and not preceded or succeeded by an unsnapped vertex
for ( int iPart = 0, nParts = subjGeom->partCount(); iPart < nParts; ++iPart )

0 comments on commit c400326

Please sign in to comment.
You can’t perform that action at this time.