Skip to content

Commit 4895c2c

Browse files
authoredFeb 2, 2018
Merge pull request #6191 from dgoedkoop/attributeformonchanged
[bugfix] Add dirty bit to attribute form
2 parents 7fb8de9 + 37fa41b commit 4895c2c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
 

‎src/gui/qgsattributeform.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ bool QgsAttributeForm::saveMultiEdits()
572572

573573
bool QgsAttributeForm::save()
574574
{
575-
if ( mIsSaving )
575+
if ( mIsSaving || !mDirty )
576576
return true;
577577

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

602602
mIsSaving = false;
603603
mUnsavedMultiEditChanges = false;
604+
mDirty = false;
604605

605606
return success;
606607
}
607608

608609
void QgsAttributeForm::resetValues()
609610
{
611+
mValuesInitialized = false;
610612
Q_FOREACH ( QgsWidgetWrapper *ww, mWidgets )
611613
{
612614
ww->setFeature( mFeature );
613615
}
616+
mValuesInitialized = true;
617+
mDirty = false;
614618
}
615619

616620
void QgsAttributeForm::resetSearch()
@@ -665,6 +669,9 @@ void QgsAttributeForm::onAttributeChanged( const QVariant &value )
665669
if ( oldValue == value && oldValue.isNull() == value.isNull() )
666670
return;
667671

672+
if ( mValuesInitialized )
673+
mDirty = true;
674+
668675
switch ( mMode )
669676
{
670677
case SingleEditMode:

‎src/gui/qgsattributeform.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
364364
QList< QgsAttributeFormWidget *> mFormWidgets;
365365
QgsExpressionContext mExpressionContext;
366366
QMap<const QgsVectorLayerJoinInfo *, QgsFeature> mJoinedFeatures;
367+
bool mValuesInitialized = false;
368+
bool mDirty = false;
367369

368370
struct ContainerInformation
369371
{

0 commit comments

Comments
 (0)
Please sign in to comment.