Skip to content

Commit

Permalink
Fix memory leaks in QgsMapCanvasSnapper
Browse files Browse the repository at this point in the history
Cherry-picked from 8b6abac
  • Loading branch information
nyalldawson committed Jun 24, 2015
1 parent 8d5c9ad commit df9e596
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/gui/qgsmapcanvassnapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,12 @@ int QgsMapCanvasSnapper::snapToBackgroundLayers( const QgsPoint& point, QList<Qg
QVector<QgsPoint> vertexPoints;
vertexPoints.append( iSegIt->beforeVertex );
vertexPoints.append( iSegIt->afterVertex );
QgsGeometry* lineB = QgsGeometry::fromPolyline( vertexPoints );

QgsGeometry* lineB = QgsGeometry::fromPolyline( vertexPoints );
QgsGeometry* intersectionPoint = lineA->intersection( lineB );
if ( intersectionPoint->type() == QGis::Point )
delete lineB;

if ( intersectionPoint && intersectionPoint->type() == QGis::Point )
{
//We have to check the intersection point is inside the tolerance distance for both layers
double toleranceA = 0;
Expand All @@ -331,8 +333,13 @@ int QgsMapCanvasSnapper::snapToBackgroundLayers( const QgsPoint& point, QList<Qg
iSegIt->snappedVertex = intersectionPoint->asPoint();
myResults.append( *iSegIt );
}
delete cursorPoint;
}
delete intersectionPoint;

}

delete lineA;
}

if ( myResults.length() > 0 )
Expand Down

0 comments on commit df9e596

Please sign in to comment.