Skip to content

Commit

Permalink
Apply @nyalldawson 's suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Apr 19, 2021
1 parent 2436f82 commit 9d274d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
12 changes: 3 additions & 9 deletions src/analysis/vector/qgsgeometrysnapper.cpp
Expand Up @@ -24,7 +24,6 @@
#include "qgssurface.h"
#include "qgsmultisurface.h"
#include "qgscurve.h"
#include "qgsgeos.h"

#include <QtConcurrentMap>
#include <geos_c.h>
Expand Down Expand Up @@ -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 )
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/analysis/vector/qgsgeometrysnapper.h
Expand Up @@ -21,6 +21,7 @@
#include "qgsabstractgeometry.h"
#include "qgspoint.h"
#include "qgsgeometry.h"
#include "qgsgeos.h"
#include "qgis_analysis.h"

#include <QMutex>
Expand Down Expand Up @@ -238,7 +239,7 @@ class QgsSnapIndex
void addSegment( const CoordIdx *idxFrom, const CoordIdx *idxTo );

GEOSSTRtree *mSTRTree = nullptr;
QList<GEOSGeometry *> mSTRTreeItems;
std::vector< geos::unique_ptr > mSTRTreeItems;
};

///@endcond
Expand Down

0 comments on commit 9d274d5

Please sign in to comment.