Skip to content

Commit db99c77

Browse files
committed
Less manual memory management
1 parent 901effc commit db99c77

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/core/expression/qgsexpressionfunction.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -4900,8 +4900,12 @@ QVariant QgsArrayFilterExpressionFunction::run( QgsExpressionNode::NodeList *arg
49004900
const QVariantList array = args->at( 0 )->eval( parent, context ).toList();
49014901

49024902
QgsExpressionContext *subContext = const_cast<QgsExpressionContext *>( context );
4903-
if ( !context )
4904-
subContext = new QgsExpressionContext();
4903+
std::unique_ptr< QgsExpressionContext > tempContext;
4904+
if ( !subContext )
4905+
{
4906+
tempContext = qgis::make_unique< QgsExpressionContext >();
4907+
subContext = tempContext.get();
4908+
}
49054909

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

4916-
if ( !context )
4917-
delete subContext;
4920+
if ( context )
4921+
delete subContext->popScope();
49184922

49194923
return result;
49204924
}

0 commit comments

Comments
 (0)