Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix memory leak instantiating QgsExpression in actions
  • Loading branch information
brushtyler committed Mar 14, 2012
1 parent 03f8636 commit 2c0fb43
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/qgsattributeaction.cpp
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2c0fb43

Please sign in to comment.