Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Attribute form: do not try to edit non-editable fields
  • Loading branch information
m-kuhn committed Sep 22, 2014
1 parent e613c8b commit b90dba4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -164,7 +164,7 @@ bool QgsAttributeForm::save()
QVariant srcVar = eww->value();
// need to check dstVar.isNull() != srcVar.isNull()
// otherwise if dstVar=NULL and scrVar=0, then dstVar = srcVar
if (( dstVar != srcVar || dstVar.isNull() != srcVar.isNull() ) && srcVar.isValid() )
if (( dstVar != srcVar || dstVar.isNull() != srcVar.isNull() ) && srcVar.isValid() && mLayer->fieldEditable( eww->fieldIdx() ) )
{
dst[eww->fieldIdx()] = srcVar;

Expand Down Expand Up @@ -205,7 +205,9 @@ bool QgsAttributeForm::save()
int n = 0;
for ( int i = 0; i < dst.count(); ++i )
{
if (( dst[i] == src[i] && dst[i].isNull() == src[i].isNull() ) || !dst[i].isValid() )
if (( dst[i] == src[i] && dst[i].isNull() == src[i].isNull() ) // If field is not changed...
|| !dst[i].isValid() // or the widget returns invalid (== do not change)
|| !mLayer->fieldEditable( i ) ) // or the field cannot be edited ...
{
continue;
}
Expand Down

0 comments on commit b90dba4

Please sign in to comment.