Skip to content
Permalink
Browse files
fix memory leak instantiating QgsExpression in actions
  • Loading branch information
brushtyler committed Mar 14, 2012
1 parent 03f8636 commit 2c0fb43986aa00fb954851d4519f9a82a1c10cef
Showing with 7 additions and 7 deletions.
  1. +7 −7 src/core/qgsattributeaction.cpp
@@ -206,26 +206,26 @@ QString QgsAttributeAction::expandAction( QString action, QgsFeature &feat, cons
index = pos + rx.matchedLength();

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

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

QgsExpression* exp = new QgsExpression( to_replace );
if ( exp->hasParserError() )
QgsExpression exp( to_replace );
if ( exp.hasParserError() )
{
QgsDebugMsg( "Expression parser error:" + exp->parserErrorString() );
QgsDebugMsg( "Expression parser error: " + exp.parserErrorString() );
expr_action += action.mid( start, index - start );
continue;
}

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

0 comments on commit 2c0fb43

Please sign in to comment.