Skip to content

Commit bbc7cba

Browse files
committed
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
1 parent 4e0431d commit bbc7cba

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/gui/qgsattributeform.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ void QgsAttributeForm::onAttributeAdded( int idx )
278278
{
279279
QgsAttributes attrs = mFeature.attributes();
280280
Q_ASSERT( attrs.size() == idx );
281-
attrs.append( QVariant() );
281+
attrs.append( QVariant( layer()->pendingFields()[idx].type() ) );
282282
mFeature.setFields( &layer()->pendingFields() );
283283
mFeature.setAttributes( attrs );
284284
}

0 commit comments

Comments
 (0)