From 36d555dd232e57ebb7ebe80ff1d4819cc8dcafb0 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Mon, 19 Apr 2021 13:36:44 +0700 Subject: [PATCH] Apply @nyalldawson 's suggestion --- src/analysis/vector/qgsgeometrysnapper.cpp | 12 +++--------- src/analysis/vector/qgsgeometrysnapper.h | 3 ++- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/analysis/vector/qgsgeometrysnapper.cpp b/src/analysis/vector/qgsgeometrysnapper.cpp index d44296696226..2c23e3e1df91 100644 --- a/src/analysis/vector/qgsgeometrysnapper.cpp +++ b/src/analysis/vector/qgsgeometrysnapper.cpp @@ -24,7 +24,6 @@ #include "qgssurface.h" #include "qgsmultisurface.h" #include "qgscurve.h" -#include "qgsgeos.h" #include #include @@ -199,12 +198,7 @@ QgsSnapIndex::~QgsSnapIndex() qDeleteAll( mCoordIdxs ); qDeleteAll( mSnapItems ); - GEOSContextHandle_t geosctxt = QgsGeos::getGEOSHandler(); - for ( GEOSGeometry *geom : mSTRTreeItems ) - { - GEOSGeom_destroy_r( geosctxt, geom ); - } - GEOSSTRtree_destroy_r( geosctxt, mSTRTree ); + GEOSSTRtree_destroy_r( QgsGeos::getGEOSHandler(), mSTRTree ); } void QgsSnapIndex::addPoint( const CoordIdx *idx, bool isEndPoint ) @@ -226,7 +220,7 @@ void QgsSnapIndex::addPoint( const CoordIdx *idx, bool isEndPoint ) PointSnapItem *item = new PointSnapItem( idx, isEndPoint ); GEOSSTRtree_insert_r( geosctxt, mSTRTree, point.get(), item ); #if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR<9 - mSTRTreeItems << point.release(); + mSTRTreeItems.push_back( std::move( point ) ); #endif mSnapItems << item; } @@ -257,7 +251,7 @@ void QgsSnapIndex::addSegment( const CoordIdx *idxFrom, const CoordIdx *idxTo ) SegmentSnapItem *item = new SegmentSnapItem( idxFrom, idxTo ); GEOSSTRtree_insert_r( geosctxt, mSTRTree, point.get(), item ); #if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR<9 - mSTRTreeItems << point.release(); + mSTRTreeItems.push_back( std::move( point ) ); #endif mSnapItems << item; } diff --git a/src/analysis/vector/qgsgeometrysnapper.h b/src/analysis/vector/qgsgeometrysnapper.h index f03bc0660794..8bf614c05520 100644 --- a/src/analysis/vector/qgsgeometrysnapper.h +++ b/src/analysis/vector/qgsgeometrysnapper.h @@ -21,6 +21,7 @@ #include "qgsabstractgeometry.h" #include "qgspoint.h" #include "qgsgeometry.h" +#include "qgsgeos.h" #include "qgis_analysis.h" #include @@ -238,7 +239,7 @@ class QgsSnapIndex void addSegment( const CoordIdx *idxFrom, const CoordIdx *idxTo ); GEOSSTRtree *mSTRTree = nullptr; - QList mSTRTreeItems; + std::vector< geos::unique_ptr > mSTRTreeItems; }; ///@endcond