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.

(cherry-picked from 2fddc00)
  • Loading branch information
nyalldawson committed May 25, 2016
1 parent 41a98ca commit 695883e94f6bc0fcdb48690cd360405d52046014
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/gui/qgsattributeform.cpp
@@ -176,9 +176,14 @@ bool QgsAttributeForm::save()
{
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 695883e

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