Skip to content

Commit

Permalink
Fix #6725
Browse files Browse the repository at this point in the history
- Restore toggle editing button state in attribute table editor if toggling canceled or commit/rollback changes fails
  • Loading branch information
dakcarto committed Jan 1, 2013
1 parent ce98348 commit d387c93
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app/qgsattributetabledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
bool canDeleteAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteAttributes;
bool canAddFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddFeatures;

mToggleEditingButton->blockSignals( true );
mToggleEditingButton->setCheckable( true );
mToggleEditingButton->setChecked( mLayer->isEditable() );
mToggleEditingButton->setEnabled( canChangeAttributes && !mLayer->isReadOnly() );
mToggleEditingButton->blockSignals( false );

mSaveEditsButton->setEnabled( canChangeAttributes && mLayer->isEditable() );
mOpenFieldCalculator->setEnabled(( canChangeAttributes || canAddAttributes ) && mLayer->isEditable() );
Expand All @@ -120,7 +122,6 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
mAddFeature->setHidden( !canAddFeatures || mLayer->geometryType() != QGis::NoGeometry );

// info from table to application
connect( this, SIGNAL( editingToggled( QgsMapLayer * ) ), QgisApp::instance(), SLOT( toggleEditing( QgsMapLayer * ) ) );
connect( this, SIGNAL( saveEdits( QgsMapLayer * ) ), QgisApp::instance(), SLOT( saveEdits( QgsMapLayer * ) ) );

// info from layer to table
Expand Down Expand Up @@ -665,7 +666,13 @@ void QgsAttributeTableDialog::on_mAdvancedSearchButton_clicked()

void QgsAttributeTableDialog::on_mToggleEditingButton_toggled()
{
emit editingToggled( mLayer );
if ( !mLayer )
return;
if ( !QgisApp::instance()->toggleEditing( mLayer ) )
{
// restore gui state if toggling was canceled or layer commit/rollback failed
editingToggled();
}
}

void QgsAttributeTableDialog::on_mSaveEditsButton_clicked()
Expand Down

0 comments on commit d387c93

Please sign in to comment.