Skip to content
Permalink
Browse files

Expressions, fix WhenThen crash and more tests

* 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 4b7235787523afe8ee85dbb2cde81da8e47add7e
Showing with 4 additions and 1 deletion.
  1. +1 −1 src/core/qgsexpression.cpp
  2. +1 −0 src/core/qgsexpression.h
  3. +2 −0 tests/src/core/testqgsexpression.cpp
@@ -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() );
}


@@ -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; }
@@ -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()

0 comments on commit 4b72357

Please sign in to comment.
You can’t perform that action at this time.