Skip to content
Permalink
Browse files

Fix memory leak

  • Loading branch information
nyalldawson committed Sep 18, 2017
1 parent 31f6a89 commit ffbb24481ba74e2820d9f2310ad1a983e6274c1b
Showing with 5 additions and 5 deletions.
  1. +5 −5 src/core/processing/qgsnativealgorithms.cpp
@@ -1432,15 +1432,15 @@ QVariantMap QgsSelectByLocationAlgorithm::processAlgorithm( const QVariantMap &p
{
QgsVectorLayer *selectLayer = parameterAsVectorLayer( parameters, QStringLiteral( "INPUT" ), context );
QgsVectorLayer::SelectBehavior method = static_cast< QgsVectorLayer::SelectBehavior >( parameterAsEnum( parameters, QStringLiteral( "METHOD" ), context ) );
QgsFeatureSource *intersectSource = parameterAsSource( parameters, QStringLiteral( "INTERSECT" ), context );
std::unique_ptr< QgsFeatureSource > intersectSource( parameterAsSource( parameters, QStringLiteral( "INTERSECT" ), context ) );
const QList< int > selectedPredicates = parameterAsEnums( parameters, QStringLiteral( "PREDICATE" ), context );

QgsFeatureIds selectedIds;
auto addToSelection = [&]( const QgsFeature & feature )
{
selectedIds.insert( feature.id() );
};
process( selectLayer, intersectSource, selectedPredicates, addToSelection, true, feedback );
process( selectLayer, intersectSource.get(), selectedPredicates, addToSelection, true, feedback );

selectLayer->selectByIds( selectedIds, method );
QVariantMap results;
@@ -1657,8 +1657,8 @@ QgsExtractByLocationAlgorithm *QgsExtractByLocationAlgorithm::createInstance() c

QVariantMap QgsExtractByLocationAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
QgsFeatureSource *input = parameterAsSource( parameters, QStringLiteral( "INPUT" ), context );
QgsFeatureSource *intersectSource = parameterAsSource( parameters, QStringLiteral( "INTERSECT" ), context );
std::unique_ptr< QgsFeatureSource > input( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
std::unique_ptr< QgsFeatureSource > intersectSource( parameterAsSource( parameters, QStringLiteral( "INTERSECT" ), context ) );
const QList< int > selectedPredicates = parameterAsEnums( parameters, QStringLiteral( "PREDICATE" ), context );
QString dest;
std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest, input->fields(), input->wkbType(), input->sourceCrs() ) );
@@ -1671,7 +1671,7 @@ QVariantMap QgsExtractByLocationAlgorithm::processAlgorithm( const QVariantMap &
QgsFeature f = feature;
sink->addFeature( f, QgsFeatureSink::FastInsert );
};
process( input, intersectSource, selectedPredicates, addToSink, false, feedback );
process( input.get(), intersectSource.get(), selectedPredicates, addToSink, false, feedback );

QVariantMap results;
results.insert( QStringLiteral( "OUTPUT" ), dest );

0 comments on commit ffbb244

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