Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a crash resulting from corrupted undo stack (fixes #11940)
In field calc opened from attribute table, when changing attributes
there is a series of signals: layer emits attributeValueChanged(),
cache forces update of attribute table data, which at one point calls
layer.isModified(), emitting beforeModifiedCheck() - in turn calling
save() of attribute form, which would change first feature's new attribute
to a bogus value. This recursive change of attribute values corrupts
the undo stack.

The fix pre-sets the feature's attribute so that no dummy entry is
added to the undo stack.

In the future we should probably try to improve the whole cascade
to avoid bugs like this one:
1. if possible, make emission of edit signals "safe", so a slot can
   do more editing calls without corrupting undo stack
2. get rid of beforeModifiedCheck() signal as it adds quite surprising
   behavior (and overhead) to what should be a simple check
  • Loading branch information
wonder-sk committed Feb 11, 2015
1 parent 4e0431d commit bbc7cba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/gui/qgsattributeform.cpp
Expand Up @@ -278,7 +278,7 @@ void QgsAttributeForm::onAttributeAdded( int idx )
{ {
QgsAttributes attrs = mFeature.attributes(); QgsAttributes attrs = mFeature.attributes();
Q_ASSERT( attrs.size() == idx ); Q_ASSERT( attrs.size() == idx );
attrs.append( QVariant() ); attrs.append( QVariant( layer()->pendingFields()[idx].type() ) );
mFeature.setFields( &layer()->pendingFields() ); mFeature.setFields( &layer()->pendingFields() );
mFeature.setAttributes( attrs ); mFeature.setAttributes( attrs );
} }
Expand Down

0 comments on commit bbc7cba

Please sign in to comment.