Skip to content

Commit

Permalink
Don't double add features
Browse files Browse the repository at this point in the history
Fix #10969
  • Loading branch information
m-kuhn committed Jul 30, 2014
1 parent 4506b81 commit 3e53c39
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/gui/qgsattributedialog.cpp
Expand Up @@ -102,6 +102,7 @@ void QgsAttributeDialog::init( QgsVectorLayer* layer, QgsFeature* feature, QgsAt
setLayout( new QGridLayout() );
layout()->setMargin( 0 );
mAttributeForm = new QgsAttributeForm( layer, *feature, context, parent );
mAttributeForm->disconnectButtonBox();
layout()->addWidget( mAttributeForm );
QDialogButtonBox* buttonBox = mAttributeForm->findChild<QDialogButtonBox*>();
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
Expand Down
9 changes: 8 additions & 1 deletion src/gui/qgsattributeform.cpp
Expand Up @@ -65,7 +65,8 @@ void QgsAttributeForm::hideButtonBox()
mButtonBox->hide();

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

void QgsAttributeForm::showButtonBox()
Expand All @@ -75,6 +76,12 @@ void QgsAttributeForm::showButtonBox()
disconnect( mLayer, SIGNAL( beforeModifiedCheck() ), this, SLOT( save() ) );
}

void QgsAttributeForm::disconnectButtonBox()
{
disconnect( mButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
disconnect( mButtonBox, SIGNAL( rejected() ), this, SLOT( resetValues() ) );
}

void QgsAttributeForm::addInterface( QgsAttributeFormInterface* iface )
{
mInterfaces.append( iface );
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgsattributeform.h
Expand Up @@ -46,6 +46,12 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
*/
void showButtonBox();

/**
* Disconnects the button box (Ok/Cancel) from the accept/resetValues slots
* If this method is called, you have to create these connections from outside
*/
void disconnectButtonBox();

/**
* Takes ownership
* @param iface
Expand Down

0 comments on commit 3e53c39

Please sign in to comment.