Skip to content
Permalink
Browse files

Split tool: prefer default values for new features vs. values copied …

…from original feature. Fixes ticket #5475
  • Loading branch information
mhugent committed May 22, 2012
1 parent 5ff3354 commit 5745fb90eed6a9314d0b005190b5954f4a3bb630
Showing with 17 additions and 1 deletion.
  1. +17 −1 src/core/qgsvectorlayer.cpp
@@ -2403,7 +2403,23 @@ int QgsVectorLayer::splitFeatures( const QList<QgsPoint>& splitLine, bool topolo
newGeometry = newGeometries.at( i );
QgsFeature newFeature;
newFeature.setGeometry( newGeometry );
newFeature.setAttributeMap( select_it->attributeMap() );

//use default value where possible (primary key issue), otherwise the value from the original (splitted) feature
QgsAttributeMap newAttributes = select_it->attributeMap();
QVariant defaultValue;
for ( int j = 0; j < newAttributes.size(); ++j )
{
if ( mDataProvider )
{
defaultValue = mDataProvider->defaultValue( j );
if ( !defaultValue.isNull() )
{
newAttributes.insert( j, defaultValue );
}
}
}

newFeature.setAttributeMap( newAttributes );
newFeatures.append( newFeature );
}

0 comments on commit 5745fb9

Please sign in to comment.
You can’t perform that action at this time.