Skip to content
Permalink
Browse files
[offline editing] fix overwriting of first field on remote layer when…
… it has virtual fields (#45002)
  • Loading branch information
3nids committed Sep 9, 2021
1 parent e05e9c0 commit 6c39e30d1cfe737b88af1c53eae63c33cfe5168a
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/core/qgsofflineediting.cpp
@@ -1020,12 +1020,16 @@ void QgsOfflineEditing::applyFeaturesAdded( QgsVectorLayer *offlineLayer, QgsVec
{
// NOTE: SpatiaLite provider ignores position of geometry column
// restore gap in QgsAttributeMap if geometry column is not last (WORKAROUND)
QMap<int, int> attrLookup = attributeLookup( offlineLayer, remoteLayer );
const QMap<int, int> attrLookup = attributeLookup( offlineLayer, remoteLayer );
QgsAttributes newAttrs( newAttrsCount );
QgsAttributes attrs = it->attributes();
for ( int it = 0; it < attrs.count(); ++it )
{
newAttrs[ attrLookup[ it ] ] = attrs.at( it );
const int remoteAttributeIndex = attrLookup.value( it, -1 );
// if virtual or non existing field
if ( remoteAttributeIndex == -1 )
continue;
newAttrs[ remoteAttributeIndex ] = attrs.at( it );
}

// respect constraints and provider default values
@@ -1739,4 +1743,3 @@ void QgsOfflineEditing::layerAdded( QgsMapLayer *layer )
connect( vLayer, &QgsVectorLayer::editingStopped, this, &QgsOfflineEditing::stopListenFeatureChanges );
}
}

0 comments on commit 6c39e30

Please sign in to comment.