Skip to content

Commit 00207c8

Browse files
committedApr 30, 2017
Also support invalid-as-null variants
1 parent 82e36f0 commit 00207c8

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed
 

‎src/core/qgsexpression.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5920,7 +5920,10 @@ bool QgsExpression::NodeCondition::isStatic( QgsExpression *parent, const QgsExp
59205920
return false;
59215921
}
59225922

5923-
return mElseExp->isStatic( parent, context );
5923+
if ( mElseExp )
5924+
return mElseExp->isStatic( parent, context );
5925+
5926+
return true;
59245927
}
59255928

59265929

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

63316334
QVariant QgsExpression::Node::eval( QgsExpression *parent, const QgsExpressionContext *context )
63326335
{
6333-
if ( mStaticValue.isValid() )
6336+
if ( mHasCachedValue )
63346337
{
6335-
return mStaticValue;
6338+
return mCachedStaticValue;
63366339
}
63376340
else
63386341
{
@@ -6345,11 +6348,13 @@ bool QgsExpression::Node::prepare( QgsExpression *parent, const QgsExpressionCon
63456348
{
63466349
if ( isStatic( parent, context ) )
63476350
{
6348-
mStaticValue = evalNode( parent, context );
6351+
mCachedStaticValue = evalNode( parent, context );
6352+
mHasCachedValue = true;
63496353
return true;
63506354
}
63516355
else
63526356
{
6357+
mHasCachedValue = false;
63536358
return prepareNode( parent, context );
63546359
}
63556360
}

‎src/core/qgsexpression.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,8 @@ class CORE_EXPORT QgsExpression
941941
*/
942942
virtual QVariant evalNode( QgsExpression *parent, const QgsExpressionContext *context ) = 0;
943943

944-
QVariant mStaticValue;
944+
bool mHasCachedValue = false;
945+
QVariant mCachedStaticValue;
945946
};
946947

947948
//! Named node

0 commit comments

Comments
 (0)
Please sign in to comment.