Skip to content
Permalink
Browse files

pass through default values when merging features (followup 099a40b, …

…refs #12842)
  • Loading branch information
jef-n committed Oct 23, 2015
1 parent 220affb commit d8303a76d45e81e49be4c87730205114aa472797
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/app/qgisapp.cpp
@@ -6208,15 +6208,20 @@ void QgisApp::mergeAttributesOfSelectedFeatures()
continue;

QVariant val = merged.at( i );
const QgsField &fld( vl->fields().at( i ) );
bool isDefaultValue = vl->fields().fieldOrigin( i ) == QgsFields::OriginProvider &&
vl->dataProvider() &&
vl->dataProvider()->defaultValue( vl->fields().fieldOriginIndex( i ) ) == val;

// convert to destination data type
if ( ! vl->fields().at( i ).convertCompatible( val ) )
if ( !isDefaultValue && !fld.convertCompatible( val ) )
{
if ( firstFeature )
{
//only warn on first feature
messageBar()->pushMessage(
tr( "Invalid result" ),
tr( "Could not store value '%1' in field of type %2" ).arg( merged.at( i ).toString(), vl->fields().at( i ).typeName() ),
tr( "Could not store value '%1' in field of type %2" ).arg( merged.at( i ).toString(), fld.typeName() ),
QgsMessageBar::WARNING );
}
}
@@ -6345,8 +6350,12 @@ void QgisApp::mergeSelectedFeatures()
for ( int i = 0; i < attrs.count(); ++i )
{
QVariant val = attrs.at( i );
bool isDefaultValue = vl->fields().fieldOrigin( i ) == QgsFields::OriginProvider &&
vl->dataProvider() &&
vl->dataProvider()->defaultValue( vl->fields().fieldOriginIndex( i ) ) == val;

// convert to destination data type
if ( ! vl->fields().at( i ).convertCompatible( val ) )
if ( !isDefaultValue && !vl->fields().at( i ).convertCompatible( val ) )
{
messageBar()->pushMessage(
tr( "Invalid result" ),

0 comments on commit d8303a7

Please sign in to comment.
You can’t perform that action at this time.