Skip to content
Permalink
Browse files

Attribute form: do not try to edit non-editable fields

  • Loading branch information
m-kuhn committed Sep 22, 2014
1 parent e613c8b commit b90dba4fd9c6631c8a63322b956facd4d621e8a7
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/gui/qgsattributeform.cpp
@@ -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;

@@ -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;
}

0 comments on commit b90dba4

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