diff --git a/src/providers/ogr/qgsogrprovider.cpp b/src/providers/ogr/qgsogrprovider.cpp index 247aa8febc38..2b77d1ada39a 100644 --- a/src/providers/ogr/qgsogrprovider.cpp +++ b/src/providers/ogr/qgsogrprovider.cpp @@ -518,7 +518,8 @@ bool QgsOgrProvider::nextFeature( QgsFeature& feature ) OGRFeatureH fet; QgsRectangle selectionRect; - setRelevantFields( mFetchGeom || mUseIntersect, mAttributesToFetch ); + setRelevantFields( mFetchGeom || mUseIntersect || !mFetchRect.isEmpty(), + mAttributesToFetch ); while (( fet = OGR_L_GetNextFeature( ogrLayer ) ) ) { @@ -616,6 +617,7 @@ void QgsOgrProvider::select( QgsAttributeList fetchAttributes, QgsRectangle rect mUseIntersect = useIntersect; mAttributesToFetch = fetchAttributes; mFetchGeom = fetchGeometry; + mFetchRect = rect; // spatial query to select features if ( rect.isEmpty() ) diff --git a/src/providers/ogr/qgsogrprovider.h b/src/providers/ogr/qgsogrprovider.h index cac6977063d0..fd4d9ce5454c 100644 --- a/src/providers/ogr/qgsogrprovider.h +++ b/src/providers/ogr/qgsogrprovider.h @@ -276,6 +276,9 @@ class QgsOgrProvider : public QgsVectorDataProvider //! layer index int mLayerIndex; + //! current spatial filter + QgsRectangle mFetchRect; + //! String used to define a subset of the layer QString mSubsetString;