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 github-actions committed Jun 8, 2021
1 parent c1e3ade commit 1b385d83d98769f9b223b9ae4162c165700d8990
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 1b385d8

Please sign in to comment.