Navigation Menu

Skip to content

Commit

Permalink
When merging features, ensure that fields with "apply default
Browse files Browse the repository at this point in the history
value on update" are correctly evaluated and the default
value used for the merged feature result
  • Loading branch information
nyalldawson committed Mar 16, 2021
1 parent f8107b4 commit 05f364b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/app/qgisapp.cpp
Expand Up @@ -10072,13 +10072,8 @@ void QgisApp::mergeSelectedFeatures()
}
}

vl->beginEditCommand( tr( "Merged features" ) );

//create new feature
QgsFeature newFeature;
newFeature.setGeometry( unionGeom );

QgsAttributes attrs = d.mergedAttributes();
QgsAttributeMap newAttributes;
QString errorMessage;
for ( int i = 0; i < attrs.count(); ++i )
{
Expand All @@ -10095,9 +10090,13 @@ void QgisApp::mergeSelectedFeatures()
tr( "Could not store value '%1' in field of type %2: %3" ).arg( attrs.at( i ).toString(), vl->fields().at( i ).typeName(), errorMessage ),
Qgis::Warning );
}
attrs[i] = val;
newAttributes[ i ] = val;
}
newFeature.setAttributes( attrs );

vl->beginEditCommand( tr( "Merged features" ) );

//create new feature
QgsFeature newFeature = QgsVectorLayerUtils::createFeature( vl, unionGeom, newAttributes );

QgsFeatureIds::const_iterator feature_it = featureIdsAfter.constBegin();
for ( ; feature_it != featureIdsAfter.constEnd(); ++feature_it )
Expand Down

0 comments on commit 05f364b

Please sign in to comment.