Skip to content
Permalink
Browse files

[bugfix] Add dirty bit to attribute form

In some cases it is difficult to prevent that an edit widget doesn't
return the original value, even if the user didn't change anything.
So rather than just comparing values to check if they have been
modified, a dirty bit has been added which is set whenever the user
actually edits the data in an edit widget. This is part of the fix
for #17878.
  • Loading branch information
dgoedkoop committed Jan 28, 2018
1 parent 285bb06 commit 37fa41b03a828bc5b16e771f6fd9d41fc0a65a2b
Showing with 10 additions and 1 deletion.
  1. +8 −1 src/gui/qgsattributeform.cpp
  2. +2 −0 src/gui/qgsattributeform.h
@@ -565,7 +565,7 @@ bool QgsAttributeForm::saveMultiEdits()

bool QgsAttributeForm::save()
{
if ( mIsSaving )
if ( mIsSaving || !mDirty )
return true;

mIsSaving = true;
@@ -594,16 +594,20 @@ bool QgsAttributeForm::save()

mIsSaving = false;
mUnsavedMultiEditChanges = false;
mDirty = false;

return success;
}

void QgsAttributeForm::resetValues()
{
mValuesInitialized = false;
Q_FOREACH ( QgsWidgetWrapper *ww, mWidgets )
{
ww->setFeature( mFeature );
}
mValuesInitialized = true;
mDirty = false;
}

void QgsAttributeForm::resetSearch()
@@ -658,6 +662,9 @@ void QgsAttributeForm::onAttributeChanged( const QVariant &value )
if ( oldValue == value && oldValue.isNull() == value.isNull() )
return;

if ( mValuesInitialized )
mDirty = true;

switch ( mMode )
{
case SingleEditMode:
@@ -364,6 +364,8 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
QList< QgsAttributeFormWidget *> mFormWidgets;
QgsExpressionContext mExpressionContext;
QMap<const QgsVectorLayerJoinInfo *, QgsFeature> mJoinedFeatures;
bool mValuesInitialized = false;
bool mDirty = false;

struct ContainerInformation
{

0 comments on commit 37fa41b

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