Skip to content

Commit

Permalink
pass through default values when merging features (followup 099a40b, …
Browse files Browse the repository at this point in the history
…refs #12842)
  • Loading branch information
jef-n committed Oct 23, 2015
1 parent 220affb commit d8303a7
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
Expand Down Expand Up @@ -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" ),
Expand Down

0 comments on commit d8303a7

Please sign in to comment.