Skip to content
Permalink
Browse files
Also support invalid-as-null variants
  • Loading branch information
m-kuhn committed Apr 30, 2017
1 parent 82e36f0 commit 00207c84aa50aed7bf826b9b0886fb44576bb9d4
Showing with 11 additions and 5 deletions.
  1. +9 −4 src/core/qgsexpression.cpp
  2. +2 −1 src/core/qgsexpression.h
@@ -5920,7 +5920,10 @@ bool QgsExpression::NodeCondition::isStatic( QgsExpression *parent, const QgsExp
return false;
}

return mElseExp->isStatic( parent, context );
if ( mElseExp )
return mElseExp->isStatic( parent, context );

return true;
}


@@ -6330,9 +6333,9 @@ QSet<QString> QgsExpression::StaticFunction::referencedColumns( const NodeFuncti

QVariant QgsExpression::Node::eval( QgsExpression *parent, const QgsExpressionContext *context )
{
if ( mStaticValue.isValid() )
if ( mHasCachedValue )
{
return mStaticValue;
return mCachedStaticValue;
}
else
{
@@ -6345,11 +6348,13 @@ bool QgsExpression::Node::prepare( QgsExpression *parent, const QgsExpressionCon
{
if ( isStatic( parent, context ) )
{
mStaticValue = evalNode( parent, context );
mCachedStaticValue = evalNode( parent, context );
mHasCachedValue = true;
return true;
}
else
{
mHasCachedValue = false;
return prepareNode( parent, context );
}
}
@@ -941,7 +941,8 @@ class CORE_EXPORT QgsExpression
*/
virtual QVariant evalNode( QgsExpression *parent, const QgsExpressionContext *context ) = 0;

QVariant mStaticValue;
bool mHasCachedValue = false;
QVariant mCachedStaticValue;
};

//! Named node

0 comments on commit 00207c8

Please sign in to comment.