Skip to content
Permalink
Browse files

Fix logic in detecting whether attribute form widgets have changed

Since two null QVariants can be reported as not equal if they have
different underlying types we need to ensure that we don't flag
this situation as a changed value.
  • Loading branch information
nyalldawson committed May 24, 2016
1 parent 38e0502 commit 2fddc0079f153c6dd7cb312c8de96548d9812094
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/gui/qgsattributeform.cpp
@@ -274,9 +274,14 @@ bool QgsAttributeForm::saveEdits()
{
QVariant dstVar = dst.at( eww->fieldIdx() );
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() && !mLayer->editFormConfig()->readOnly( eww->fieldIdx() ) )
// be careful- sometimes two null qvariants will be reported as not equal!! (eg different types)
bool changed = ( dstVar != srcVar && !dstVar.isNull() && !srcVar.isNull() )
|| ( dstVar.isNull() != srcVar.isNull() );
if ( changed && srcVar.isValid()
&& !mLayer->editFormConfig()->readOnly( eww->fieldIdx() ) )
{
dst[eww->fieldIdx()] = srcVar;

0 comments on commit 2fddc00

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