Skip to content
Permalink
Browse files

Make sure that relevant fields are set always when necessary.

  • Loading branch information
wonder-sk committed Nov 7, 2011
1 parent 625ff11 commit 8e2e654c448d7f035697a1351af88c847797b99b
Showing with 20 additions and 0 deletions.
  1. +13 −0 src/providers/ogr/qgsogrprovider.cpp
  2. +7 −0 src/providers/ogr/qgsogrprovider.h
@@ -556,6 +556,10 @@ void QgsOgrProvider::setRelevantFields( bool fetchGeometry, const QgsAttributeLi

OGR_L_SetIgnoredFields( ogrLayer, ignoredFields.data() );
}

// mark that relevant fields may not be set appropriately for nextFeature() calls
mRelevantFieldsForNextFeature = false;

#else
Q_UNUSED( fetchGeometry );
Q_UNUSED( fetchAttributes );
@@ -623,6 +627,14 @@ bool QgsOgrProvider::nextFeature( QgsFeature& feature )
return false;
}

if ( !mRelevantFieldsForNextFeature )
{
// setting relevant fields has some overhead so set it only when necessary
setRelevantFields( mFetchGeom || mUseIntersect || !mFetchRect.isEmpty(),
mAttributesToFetch );
mRelevantFieldsForNextFeature = true;
}

OGRFeatureH fet;
QgsRectangle selectionRect;

@@ -726,6 +738,7 @@ void QgsOgrProvider::select( QgsAttributeList fetchAttributes, QgsRectangle rect

setRelevantFields( mFetchGeom || mUseIntersect || !mFetchRect.isEmpty(),
mAttributesToFetch );
mRelevantFieldsForNextFeature = true;

// spatial query to select features
if ( rect.isEmpty() )
@@ -334,6 +334,13 @@ class QgsOgrProvider : public QgsVectorDataProvider
int geomType;
long featuresCounted;

/** Flag whether OGR will return fields required by nextFeature() calls.
The relevant fields are first set in select(), however the setting may be
interferred by some other calls. This flag ensures they are set again
to correct values.
*/
bool mRelevantFieldsForNextFeature;

//! Selection rectangle
OGRGeometryH mSelectionRectangle;
/**Adds one feature*/

0 comments on commit 8e2e654

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