Skip to content

Commit 64d1c02

Browse files
committedJul 27, 2012
import vector layer: do not change attribute map of the source feature,
do not copy values of un-mapped attributes forward to the destination layer: avoid features with dirty attribute maps being added to the buffer
1 parent 237baea commit 64d1c02

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed
 

‎src/core/qgsvectorlayerimport.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,21 @@ bool QgsVectorLayerImport::addFeature( QgsFeature& feat )
120120
{
121121
const QgsAttributeMap &attrs = feat.attributeMap();
122122

123-
QgsAttributeMap newAttrs;
123+
QgsFeature newFeat;
124+
newFeat.setGeometry( *feat.geometry() );
125+
124126
for ( QgsAttributeMap::const_iterator it = attrs.begin(); it != attrs.end(); it++ )
125127
{
128+
// add only mapped attributes (un-mapped ones are not present in the
129+
// destination layer)
126130
if ( mOldToNewAttrIdx.contains( it.key() ) )
127131
{
128132
QgsDebugMsgLevel( QString( "moving field from pos %1 to %2" ).arg( it.key() ).arg( mOldToNewAttrIdx.value( it.key() ) ), 3 );
129-
newAttrs.insert( mOldToNewAttrIdx.value( it.key() ), *it );
130-
}
131-
else
132-
{
133-
QgsDebugMsgLevel( QString( "added attr pos %1" ).arg( it.key() ), 3 );
134-
newAttrs.insert( it.key(), *it );
133+
newFeat.addAttribute( mOldToNewAttrIdx.value( it.key() ), *it );
135134
}
136135
}
137-
feat.setAttributeMap( newAttrs );
138136

139-
mFeatureBuffer.append( feat );
137+
mFeatureBuffer.append( newFeat );
140138

141139
if ( mFeatureBuffer.count() >= FEATURE_BUFFER_SIZE )
142140
{

0 commit comments

Comments
 (0)
Please sign in to comment.