Skip to content
Permalink
Browse files

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 bbc7cba53f0052a03686d383419a8e6793063bdc
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/gui/qgsattributeform.cpp
@@ -278,7 +278,7 @@ void QgsAttributeForm::onAttributeAdded( int idx )
{
QgsAttributes attrs = mFeature.attributes();
Q_ASSERT( attrs.size() == idx );
attrs.append( QVariant() );
attrs.append( QVariant( layer()->pendingFields()[idx].type() ) );
mFeature.setFields( &layer()->pendingFields() );
mFeature.setAttributes( attrs );
}

0 comments on commit bbc7cba

Please sign in to comment.
You can’t perform that action at this time.