Skip to content

Commit

Permalink
Less manual memory management
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 23, 2018
1 parent 901effc commit db99c77
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/core/expression/qgsexpressionfunction.cpp
Expand Up @@ -4900,8 +4900,12 @@ QVariant QgsArrayFilterExpressionFunction::run( QgsExpressionNode::NodeList *arg
const QVariantList array = args->at( 0 )->eval( parent, context ).toList();

QgsExpressionContext *subContext = const_cast<QgsExpressionContext *>( context );
if ( !context )
subContext = new QgsExpressionContext();
std::unique_ptr< QgsExpressionContext > tempContext;
if ( !subContext )
{
tempContext = qgis::make_unique< QgsExpressionContext >();
subContext = tempContext.get();
}

QgsExpressionContextScope *subScope = new QgsExpressionContextScope();
subContext->appendScope( subScope );
Expand All @@ -4913,8 +4917,8 @@ QVariant QgsArrayFilterExpressionFunction::run( QgsExpressionNode::NodeList *arg
result << value;
}

if ( !context )
delete subContext;
if ( context )
delete subContext->popScope();

return result;
}
Expand Down

0 comments on commit db99c77

Please sign in to comment.