Skip to content

Commit

Permalink
Also support invalid-as-null variants
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 30, 2017
1 parent 82e36f0 commit 00207c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/core/qgsexpression.cpp
Expand Up @@ -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;
}


Expand Down Expand Up @@ -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
{
Expand All @@ -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 );
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsexpression.h
Expand Up @@ -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
Expand Down

0 comments on commit 00207c8

Please sign in to comment.