Skip to content
Permalink
Browse files

QgsVectorLayer: use featureAtId() in selectedFeatures() (fixes #4856)

  • Loading branch information
jef-n committed Jan 24, 2012
1 parent 3903fa4 commit 0b1fd34c3e1470c6c1c1a699c581b941cfb32a03
Showing with 4 additions and 35 deletions.
  1. +4 −35 src/core/qgsvectorlayer.cpp
@@ -3971,44 +3971,13 @@ const QgsFeatureIds& QgsVectorLayer::selectedFeaturesIds() const

QgsFeatureList QgsVectorLayer::selectedFeatures()
{
if ( !mDataProvider )
{
return QgsFeatureList();
}

QgsFeatureList features;

QgsAttributeList allAttrs = mDataProvider->attributeIndexes();
mFetchAttributes = pendingAllAttributesList();

for ( QgsFeatureIds::iterator it = mSelectedFeatureIds.begin(); it != mSelectedFeatureIds.end(); ++it )
foreach( QgsFeatureId fid, mSelectedFeatureIds )
{
QgsFeature feat;

bool selectionIsAddedFeature = false;

// Check this selected item against the uncommitted added features
for ( QgsFeatureList::iterator iter = mAddedFeatures.begin(); iter != mAddedFeatures.end(); ++iter )
{
if ( *it == iter->id() )
{
feat = QgsFeature( *iter );
selectionIsAddedFeature = true;
break;
}
}

// if the geometry is not newly added, get it from provider
if ( !selectionIsAddedFeature )
{
mDataProvider->featureAtId( *it, feat, true, allAttrs );
}

updateFeatureAttributes( feat );
updateFeatureGeometry( feat );

features << feat;
} // for each selected
features.push_back( QgsFeature() );
featureAtId( fid, features.back(), true, true );
}

return features;
}

0 comments on commit 0b1fd34

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