Skip to content

Commit 4ba2c39

Browse files
jef-nalexbruy
authored andcommittedFeb 11, 2012
execute undo stack on rollBack() (fixes #4635)
1 parent 09ce9d4 commit 4ba2c39

File tree

1 file changed

+11
-29
lines changed

1 file changed

+11
-29
lines changed
 

‎src/core/qgsvectorlayer.cpp

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,41 +3772,22 @@ bool QgsVectorLayer::rollBack()
37723772

37733773
if ( isModified() )
37743774
{
3775-
while ( mAddedAttributeIds.size() > 0 )
3775+
while ( undoStack()->canUndo() )
37763776
{
3777-
int idx = *mAddedAttributeIds.begin();
3778-
mAddedAttributeIds.remove( idx );
3779-
mUpdatedFields.remove( idx );
3780-
emit attributeDeleted( idx );
3777+
undoStack()->undo();
37813778
}
37823779

3783-
while ( mDeletedAttributeIds.size() > 0 )
3784-
{
3785-
int idx = *mDeletedAttributeIds.begin();
3786-
mDeletedAttributeIds.remove( idx );
3787-
emit attributeAdded( idx );
3788-
}
3789-
3790-
// roll back changed attribute values
3791-
mChangedAttributeValues.clear();
3792-
3793-
// roll back changed geometries
3794-
mChangedGeometries.clear();
3795-
3796-
// Roll back added features
3797-
// Delete the features themselves before deleting the references to them.
3798-
mAddedFeatures.clear();
3799-
3800-
// Roll back deleted features
3801-
mDeletedFeatureIds.clear();
3780+
Q_ASSERT( mAddedAttributeIds.isEmpty() );
3781+
Q_ASSERT( mDeletedAttributeIds.isEmpty() );
3782+
Q_ASSERT( mChangedAttributeValues.isEmpty() );
3783+
Q_ASSERT( mChangedGeometries.isEmpty() );
3784+
Q_ASSERT( mAddedFeatures.isEmpty() );
38023785

38033786
updateFieldMap();
38043787
}
38053788

38063789
deleteCachedGeometries();
38073790

3808-
undoStack()->clear();
3809-
38103791
mEditable = false;
38113792
emit editingStopped();
38123793

@@ -4741,13 +4722,12 @@ void QgsVectorLayer::redoEditCommand( QgsUndoCommand* cmd )
47414722
if ( attrChIt.value().target.isNull() )
47424723
{
47434724
mChangedAttributeValues[fid].remove( attrChIt.key() );
4725+
if ( mChangedAttributeValues[fid].isEmpty() )
4726+
mChangedAttributeValues.remove( fid );
47444727
}
47454728
else
47464729
{
47474730
mChangedAttributeValues[fid][attrChIt.key()] = attrChIt.value().target;
4748-
QgsFeature f;
4749-
featureAtId( fid, f, false, true );
4750-
f.changeAttribute( attrChIt.key(), attrChIt.value().target );
47514731
}
47524732
}
47534733
else
@@ -4871,6 +4851,8 @@ void QgsVectorLayer::undoEditCommand( QgsUndoCommand* cmd )
48714851
if ( attrChIt.value().isFirstChange )
48724852
{
48734853
mChangedAttributeValues[fid].remove( attrChIt.key() );
4854+
if ( mChangedAttributeValues[fid].isEmpty() )
4855+
mChangedAttributeValues.remove( fid );
48744856
}
48754857
else
48764858
{

0 commit comments

Comments
 (0)
Please sign in to comment.