Skip to content


Browse files Browse the repository at this point in the history
When Stopping Editing and Saving Changes, if the commit was *unsucces…
…sful*, retain the in-memory edits. Previously the in-memory edits would be erased anyway.

Note this is not a complete solution as commits are currently a 3- or 4-stage process, and if one stage fails the chain cannot always be rolled-back easily.  If this is the case then a detailed error message is given to the user to assist their understanding of the discrepency.

This commit should be a bug fix for trac #131, but I don't have the environment to test it fully - the bug submitter will have to assist there.

Bonus feature: Tidied up some variable names in QgsVectorLayer - makes it clearer what they contain.

git-svn-id: c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
morb_au committed Jul 14, 2006
1 parent ae747bf commit 38dabe5
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 94 deletions.
30 changes: 17 additions & 13 deletions src/gui/qgsattributetable.cpp
Expand Up @@ -369,6 +369,8 @@ void QgsAttributeTable::deleteAttribute(const QString& name)

/* Deprecated: See QgisApp::editCopy() instead */
void QgsAttributeTable::copySelectedRows()
// Copy selected rows to the clipboard
Expand Down Expand Up @@ -413,21 +415,23 @@ void QgsAttributeTable::copySelectedRows()

bool QgsAttributeTable::commitChanges(QgsVectorLayer* layer)
bool returnvalue=true;
if(!layer->commitAttributeChanges(mDeletedAttributes, mAddedAttributes, mChangedValues))
bool isSuccessful = FALSE;

isSuccessful = layer->commitAttributeChanges(

if (isSuccessful)
return returnvalue;

return isSuccessful;

bool QgsAttributeTable::rollBack(QgsVectorLayer* layer)
Expand Down
20 changes: 17 additions & 3 deletions src/gui/qgsattributetable.h
Expand Up @@ -70,11 +70,25 @@ class QgsAttributeTable:public Q3Table
/**Deletes an attribute (but does not commit it)
@param name attribute name*/
void deleteAttribute(const QString& name);
/**Copies the selected rows to the clipboard */

/** Copies the selected rows to the clipboard
Deprecated: See QgisApp::editCopy() instead */
void copySelectedRows();
/**Delegates to QgsVectorLayer to decide, which changes
belong to not commited features or to commited ones*/

Attempts to commit any changes to disk. Returns the result of the attempt.
If a commit fails, the in-memory changes are left alone.
This allows editing to continue if the commit failed on e.g. a
disallowed value in a Postgres database - the user can re-edit and try
Delegates to QgsVectorLayer to decide, which changes
belong to not commited features or to commited ones.
bool commitChanges(QgsVectorLayer* layer);

/**Discard all changes and restore
the state before editing was started*/
bool rollBack(QgsVectorLayer* layer);
Expand Down

0 comments on commit 38dabe5

Please sign in to comment.