Skip to content
Permalink
Browse files

When merging features, ensure that fields with "apply default

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 05f364bd313901a7c11b55978a263b0146b14d1d
Showing with 7 additions and 8 deletions.
  1. +7 −8 src/app/qgisapp.cpp
@@ -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 )
{
@@ -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 )

0 comments on commit 05f364b

Please sign in to comment.