Skip to content

Commit 3e53c39

Browse files
committed
Don't double add features
Fix #10969
1 parent 4506b81 commit 3e53c39

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/gui/qgsattributedialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ void QgsAttributeDialog::init( QgsVectorLayer* layer, QgsFeature* feature, QgsAt
102102
setLayout( new QGridLayout() );
103103
layout()->setMargin( 0 );
104104
mAttributeForm = new QgsAttributeForm( layer, *feature, context, parent );
105+
mAttributeForm->disconnectButtonBox();
105106
layout()->addWidget( mAttributeForm );
106107
QDialogButtonBox* buttonBox = mAttributeForm->findChild<QDialogButtonBox*>();
107108
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );

src/gui/qgsattributeform.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ void QgsAttributeForm::hideButtonBox()
6565
mButtonBox->hide();
6666

6767
// Make sure that changes are taken into account if somebody tries to figure out if there have been some
68-
connect( mLayer, SIGNAL( beforeModifiedCheck() ), this, SLOT( save() ) );
68+
if ( !mIsAddDialog )
69+
connect( mLayer, SIGNAL( beforeModifiedCheck() ), this, SLOT( save() ) );
6970
}
7071

7172
void QgsAttributeForm::showButtonBox()
@@ -75,6 +76,12 @@ void QgsAttributeForm::showButtonBox()
7576
disconnect( mLayer, SIGNAL( beforeModifiedCheck() ), this, SLOT( save() ) );
7677
}
7778

79+
void QgsAttributeForm::disconnectButtonBox()
80+
{
81+
disconnect( mButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
82+
disconnect( mButtonBox, SIGNAL( rejected() ), this, SLOT( resetValues() ) );
83+
}
84+
7885
void QgsAttributeForm::addInterface( QgsAttributeFormInterface* iface )
7986
{
8087
mInterfaces.append( iface );

src/gui/qgsattributeform.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
4646
*/
4747
void showButtonBox();
4848

49+
/**
50+
* Disconnects the button box (Ok/Cancel) from the accept/resetValues slots
51+
* If this method is called, you have to create these connections from outside
52+
*/
53+
void disconnectButtonBox();
54+
4955
/**
5056
* Takes ownership
5157
* @param iface

0 commit comments

Comments
 (0)