Skip to content

Commit

Permalink
Do not set initial attr values for default clause
Browse files Browse the repository at this point in the history
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 3e0a965
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/app/qgsfeatureaction.cpp
Expand Up @@ -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] );
}
}

Expand Down

0 comments on commit 3e0a965

Please sign in to comment.