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 8, 2021
1 parent b8b3bf2 commit 88d863660c2aa188104ddd09b4f5ebfeaaf0960e
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 88d8636

Please sign in to comment.