Skip to content

Commit 2c0fb43

Browse files
committed
fix memory leak instantiating QgsExpression in actions
1 parent 03f8636 commit 2c0fb43

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/core/qgsattributeaction.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -206,26 +206,26 @@ QString QgsAttributeAction::expandAction( QString action, QgsFeature &feat, cons
206206
index = pos + rx.matchedLength();
207207

208208
QString to_replace = rx.cap( 1 ).trimmed();
209-
QgsDebugMsg( "Found expression:" + to_replace );
209+
QgsDebugMsg( "Found expression: " + to_replace );
210210

211211
if ( substitutionMap && substitutionMap->contains( to_replace ) )
212212
{
213213
expr_action += action.mid( start, pos - start ) + substitutionMap->value( to_replace ).toString();
214214
continue;
215215
}
216216

217-
QgsExpression* exp = new QgsExpression( to_replace );
218-
if ( exp->hasParserError() )
217+
QgsExpression exp( to_replace );
218+
if ( exp.hasParserError() )
219219
{
220-
QgsDebugMsg( "Expression parser error:" + exp->parserErrorString() );
220+
QgsDebugMsg( "Expression parser error: " + exp.parserErrorString() );
221221
expr_action += action.mid( start, index - start );
222222
continue;
223223
}
224224

225-
QVariant result = exp->evaluate( &feat, mLayer->pendingFields() );
226-
if ( exp->hasEvalError() )
225+
QVariant result = exp.evaluate( &feat, mLayer->pendingFields() );
226+
if ( exp.hasEvalError() )
227227
{
228-
QgsDebugMsg( "Expression parser eval error:" + exp->evalErrorString() );
228+
QgsDebugMsg( "Expression parser eval error: " + exp.evalErrorString() );
229229
expr_action += action.mid( start, index - start );
230230
continue;
231231
}

0 commit comments

Comments
 (0)