Skip to content

Commit

Permalink
QgsVectorLayer: use featureAtId() in selectedFeatures() (fixes #4856)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jan 24, 2012
1 parent 3903fa4 commit 0b1fd34
Showing 1 changed file with 4 additions and 35 deletions.
39 changes: 4 additions & 35 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0b1fd34

Please sign in to comment.