Skip to content

Commit

Permalink
Removed redundant check for isValid
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Feb 20, 2019
1 parent 2604fc7 commit 4250ef2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/qgsvectorlayerutils.cpp
Expand Up @@ -494,8 +494,8 @@ QgsFeatureList QgsVectorLayerUtils::createFeatures( const QgsVectorLayer *layer,

// 2. client side default expression
// note - deliberately not using else if!
if ( ( ! v.isValid() || v.isNull() || ( hasUniqueConstraint
&& uniqueValueCaches[ idx ].contains( v ) ) )
if ( ( v.isNull() || ( hasUniqueConstraint
&& uniqueValueCaches[ idx ].contains( v ) ) )
&& layer->defaultValueDefinition( idx ).isValid() )
{
// client side default expression set - takes precedence over all. Why? Well, this is the only default
Expand All @@ -506,8 +506,8 @@ QgsFeatureList QgsVectorLayerUtils::createFeatures( const QgsVectorLayer *layer,

// 3. provider side default value clause
// note - not an else if deliberately. Users may return null from a default value expression to fallback to provider defaults
if ( ( ! v.isValid() || v.isNull() || ( hasUniqueConstraint
&& uniqueValueCaches[ idx ].contains( v ) ) )
if ( ( v.isNull() || ( hasUniqueConstraint
&& uniqueValueCaches[ idx ].contains( v ) ) )
&& fields.fieldOrigin( idx ) == QgsFields::OriginProvider )
{
int providerIndex = fields.fieldOriginIndex( idx );
Expand All @@ -521,8 +521,8 @@ QgsFeatureList QgsVectorLayerUtils::createFeatures( const QgsVectorLayer *layer,

// 4. provider side default literal
// note - deliberately not using else if!
if ( ( ! v.isValid() || v.isNull() || ( checkUnique && hasUniqueConstraint
&& uniqueValueCaches[ idx ].contains( v ) ) )
if ( ( v.isNull() || ( checkUnique && hasUniqueConstraint
&& uniqueValueCaches[ idx ].contains( v ) ) )
&& fields.fieldOrigin( idx ) == QgsFields::OriginProvider )
{
int providerIndex = fields.fieldOriginIndex( idx );
Expand All @@ -536,7 +536,7 @@ QgsFeatureList QgsVectorLayerUtils::createFeatures( const QgsVectorLayer *layer,

// 5. passed attribute value
// note - deliberately not using else if!
if ( ( !v.isValid() || v.isNull() ) && fd.attributes().contains( idx ) )
if ( v.isNull() && fd.attributes().contains( idx ) )
{
v = fd.attributes().value( idx );
}
Expand Down

0 comments on commit 4250ef2

Please sign in to comment.