Skip to content

Commit

Permalink
[offline editing] fix overwriting of first field on remote layer when…
Browse files Browse the repository at this point in the history
… it has virtual fields (#45003)
  • Loading branch information
3nids committed Sep 9, 2021
1 parent 0a7bcf3 commit 0a9afa0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -963,12 +963,15 @@ 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 )
{
int remoteAttributeIndex = attrLookup[ it ];
const int remoteAttributeIndex = attrLookup.value( it, -1 );
// if virtual or non existing field
if ( remoteAttributeIndex == -1 )
continue;
QVariant attr = attrs.at( it );
if ( remoteLayer->fields().at( remoteAttributeIndex ).type() == QVariant::StringList )
{
Expand Down Expand Up @@ -1614,4 +1617,3 @@ void QgsOfflineEditing::setupLayer( QgsMapLayer *layer )
}
}
}

0 comments on commit 0a9afa0

Please sign in to comment.