@@ -62,13 +62,20 @@ QgsAttributeTableModel::QgsAttributeTableModel( QgsVectorLayerCache *layerCache,
62
62
63
63
loadAttributes ();
64
64
65
- connect ( mLayerCache , &QgsVectorLayerCache::attributeValueChanged, this , &QgsAttributeTableModel::attributeValueChanged );
66
65
connect ( layer (), &QgsVectorLayer::featuresDeleted, this , &QgsAttributeTableModel::featuresDeleted );
67
66
connect ( layer (), &QgsVectorLayer::attributeDeleted, this , &QgsAttributeTableModel::attributeDeleted );
68
67
connect ( layer (), &QgsVectorLayer::updatedFields, this , &QgsAttributeTableModel::updatedFields );
68
+
69
+ connect ( layer (), &QgsVectorLayer::editCommandStarted, this , [ = ]( const QString ) { mBulkEditCommandRunning = true ; } );
70
+ connect ( layer (), &QgsVectorLayer::editCommandEnded, this , [ = ] { mBulkEditCommandRunning = false ; } );
71
+ connect ( layer (), &QgsVectorLayer::beforeRollBack, this , [ = ] { mBulkEditCommandRunning = true ; } );
72
+ connect ( layer (), &QgsVectorLayer::afterRollBack, this , [ = ] { mBulkEditCommandRunning = false ; } );
73
+
69
74
connect ( layer (), &QgsVectorLayer::editCommandEnded, this , &QgsAttributeTableModel::editCommandEnded );
75
+ connect ( mLayerCache , &QgsVectorLayerCache::attributeValueChanged, this , &QgsAttributeTableModel::attributeValueChanged );
70
76
connect ( mLayerCache , &QgsVectorLayerCache::featureAdded, this , [ = ]( QgsFeatureId id ) { featureAdded ( id ); } );
71
77
connect ( mLayerCache , &QgsVectorLayerCache::cachedLayerDeleted, this , &QgsAttributeTableModel::layerDeleted );
78
+
72
79
}
73
80
74
81
bool QgsAttributeTableModel::loadFeatureAtId ( QgsFeatureId fid ) const
@@ -294,6 +301,9 @@ void QgsAttributeTableModel::fieldFormatterRemoved( QgsFieldFormatter *fieldForm
294
301
295
302
void QgsAttributeTableModel::attributeValueChanged ( QgsFeatureId fid, int idx, const QVariant &value )
296
303
{
304
+ // Skip all updates if an edit command is running
305
+ if ( mBulkEditCommandRunning )
306
+ return ;
297
307
QgsDebugMsgLevel ( QStringLiteral ( " (%4) fid: %1, idx: %2, value: %3" ).arg ( fid ).arg ( idx ).arg ( value.toString () ).arg ( mFeatureRequest .filterType () ), 3 );
298
308
299
309
for ( SortCache &cache : mSortCaches )
0 commit comments