Skip to content
Permalink
Browse files
Do not set initial attr values for default clause
Fixes #42909

Setting intial values from previously entered values when
they are equal to the default was pointless anyway because
QgsVectorLayerUtils::createFeature will do that a few lines
below.

Setting the default value for unique constraints
was triggering unique checks for no reason and slowing down
the feature creation up to the point that for large layers
QGIS froze.
  • Loading branch information
elpaso authored and nyalldawson committed Jun 21, 2021
1 parent 5beab1d commit 3e0a96556058091702b68286ad2895f8f253d7ce
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/app/qgsfeatureaction.cpp
@@ -189,7 +189,10 @@ bool QgsFeatureAction::addFeature( const QgsAttributeMap &defaultAttributes, boo
}
else if ( reuseLastValues && sLastUsedValues()->contains( mLayer ) && ( *sLastUsedValues() )[ mLayer ].contains( idx ) )
{
initialAttributeValues.insert( idx, ( *sLastUsedValues() )[ mLayer ][idx] );
// Only set initial attribute value if it's different from the default clause or we may trigger
// unique constraint checks for no reason, see https://github.com/qgis/QGIS/issues/42909
if ( mLayer->dataProvider()->defaultValueClause( idx ) != ( *sLastUsedValues() )[ mLayer ][idx] )
initialAttributeValues.insert( idx, ( *sLastUsedValues() )[ mLayer ][idx] );
}
}

0 comments on commit 3e0a965

Please sign in to comment.