Skip to content

Commit 8b6abac

Browse files
committed
Fix memory leaks in QgsMapCanvasSnapper
1 parent 0df0986 commit 8b6abac

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/gui/qgsmapcanvassnapper.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,12 @@ int QgsMapCanvasSnapper::snapToBackgroundLayers( const QgsPoint& point, QList<Qg
305305
QVector<QgsPoint> vertexPoints;
306306
vertexPoints.append( iSegIt->beforeVertex );
307307
vertexPoints.append( iSegIt->afterVertex );
308-
QgsGeometry* lineB = QgsGeometry::fromPolyline( vertexPoints );
309308

309+
QgsGeometry* lineB = QgsGeometry::fromPolyline( vertexPoints );
310310
QgsGeometry* intersectionPoint = lineA->intersection( lineB );
311-
if ( intersectionPoint->type() == QGis::Point )
311+
delete lineB;
312+
313+
if ( intersectionPoint && intersectionPoint->type() == QGis::Point )
312314
{
313315
//We have to check the intersection point is inside the tolerance distance for both layers
314316
double toleranceA = 0;
@@ -331,8 +333,13 @@ int QgsMapCanvasSnapper::snapToBackgroundLayers( const QgsPoint& point, QList<Qg
331333
iSegIt->snappedVertex = intersectionPoint->asPoint();
332334
myResults.append( *iSegIt );
333335
}
336+
delete cursorPoint;
334337
}
338+
delete intersectionPoint;
339+
335340
}
341+
342+
delete lineA;
336343
}
337344

338345
if ( myResults.length() > 0 )

0 commit comments

Comments
 (0)