Skip to content

Commit

Permalink
Expressions, fix WhenThen crash and more tests
Browse files Browse the repository at this point in the history
* Fix a crash with WhenThenList
* Check implicit sharing with all test expressions.
  • Loading branch information
m-kuhn committed Dec 24, 2015
1 parent 88a197b commit 4b72357
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/qgsexpression.cpp
Expand Up @@ -4189,7 +4189,7 @@ QgsExpression::Node* QgsExpression::NodeCondition::clone() const
WhenThenList conditions;
Q_FOREACH ( WhenThen* wt, mConditions )
conditions.append( new WhenThen( wt->mWhenExp->clone(), wt->mThenExp->clone() ) );
return new NodeCondition( &conditions, mElseExp->clone() );
return new NodeCondition( conditions, mElseExp->clone() );
}


Expand Down
1 change: 1 addition & 0 deletions src/core/qgsexpression.h
Expand Up @@ -966,6 +966,7 @@ class CORE_EXPORT QgsExpression
{
public:
NodeCondition( WhenThenList* conditions, Node* elseExp = nullptr ) : mConditions( *conditions ), mElseExp( elseExp ) { delete conditions; }
NodeCondition( const WhenThenList& conditions, Node* elseExp = nullptr ) : mConditions( conditions ), mElseExp( elseExp ) {}
~NodeCondition() { delete mElseExp; qDeleteAll( mConditions ); }

virtual NodeType nodeType() const override { return ntCondition; }
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgsexpression.cpp
Expand Up @@ -827,6 +827,8 @@ class TestQgsExpression: public QObject
run_evaluation_test( exp2, evalError, result );
QgsExpression exp3( exp.expression() );
run_evaluation_test( exp3, evalError, result );
QgsExpression exp4( exp );
run_evaluation_test( exp4, evalError, result );
}

void eval_precedence()
Expand Down

0 comments on commit 4b72357

Please sign in to comment.