Skip to content

Commit

Permalink
attribute form: allow overwriting invalid source attribute values and…
Browse files Browse the repository at this point in the history
… skip empty edit commands (fixes #10360)
  • Loading branch information
jef-n committed Jun 13, 2014
1 parent 406fab2 commit 74a7503
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -188,15 +188,24 @@ bool QgsAttributeForm::save()
{
mLayer->beginEditCommand( mEditCommandMessage );

int n = 0;
for ( int i = 0; i < dst.count(); ++i )
{
if ( dst[i] == src[i] || !src[i].isValid() )
if ( dst[i] == src[i] || !dst[i].isValid() )
{
QgsDebugMsg( "equal or invalid destination" );
QgsDebugMsg( QString( "dst:'%1' (type:%2,isNull:%3,isValid:%4)" )
.arg( dst[i].toString() ).arg( dst[i].typeName() ).arg( dst[i].isNull() ).arg( dst[i].isValid() ) );
QgsDebugMsg( QString( "src:'%1' (type:%2,isNull:%3,isValid:%4)" )
.arg( src[i].toString() ).arg( src[i].typeName() ).arg( src[i].isNull() ).arg( src[i].isValid() ) );
continue;
}

success &= mLayer->changeAttributeValue( mFeature.id(), i, dst[i], src[i] );
n++;
}

if ( success )
if ( success && n > 0 )
{
mLayer->endEditCommand();
mFeature.setAttributes( dst );
Expand Down

0 comments on commit 74a7503

Please sign in to comment.