Navigation Menu

Skip to content

Commit

Permalink
Evaluate defaults when adding new features in transaction group
Browse files Browse the repository at this point in the history
Fixes #37222
  • Loading branch information
elpaso authored and nyalldawson committed Jun 19, 2020
1 parent 4dc9b38 commit 2e6fdbe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/app/qgsfeatureaction.cpp
Expand Up @@ -249,6 +249,18 @@ bool QgsFeatureAction::addFeature( const QgsAttributeMap &defaultAttributes, boo
}
else
{
// If the layer is inside a transaction group we need to add
// the feature first to get the provider-evaluated defaults
const bool inTransaction { mLayer->dataProvider() &&
mLayer->dataProvider()->transaction() };
if ( inTransaction )
{
if ( mLayer->addFeature( *mFeature ) )
{
mLayer->deleteFeature( mFeature->id() );
}
}

QgsAttributeDialog *dialog = newDialog( false );
// delete the dialog when it is closed
dialog->setAttribute( Qt::WA_DeleteOnClose );
Expand Down

0 comments on commit 2e6fdbe

Please sign in to comment.