[QGIS Commit] r15395 - trunk/qgis/src/providers/ogr

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Mar 8 18:05:25 EST 2011


Author: jef
Date: 2011-03-08 15:05:25 -0800 (Tue, 08 Mar 2011)
New Revision: 15395

Modified:
   trunk/qgis/src/providers/ogr/qgsogrprovider.cpp
   trunk/qgis/src/providers/ogr/qgsogrprovider.h
Log:
fix #3542

Modified: trunk/qgis/src/providers/ogr/qgsogrprovider.cpp
===================================================================
--- trunk/qgis/src/providers/ogr/qgsogrprovider.cpp	2011-03-08 22:28:50 UTC (rev 15394)
+++ trunk/qgis/src/providers/ogr/qgsogrprovider.cpp	2011-03-08 23:05:25 UTC (rev 15395)
@@ -416,7 +416,7 @@
   return ogrDriverName;
 }
 
-void QgsOgrProvider::setIgnoredFields( bool fetchGeometry, const QgsAttributeList& fetchAttributes )
+void QgsOgrProvider::setRelevantFields( bool fetchGeometry, const QgsAttributeList &fetchAttributes )
 {
 #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
   if ( OGR_L_TestCapability( ogrLayer, OLCIgnoreFields ) )
@@ -447,7 +447,7 @@
                                   bool fetchGeometry,
                                   QgsAttributeList fetchAttributes )
 {
-  setIgnoredFields( fetchGeometry, fetchAttributes );
+  setRelevantFields( fetchGeometry, fetchAttributes );
 
   OGRFeatureH fet = OGR_L_GetFeature( ogrLayer, featureId );
   if ( fet == NULL )
@@ -462,7 +462,6 @@
     return false;
   }
 
-
   /* fetch geometry */
   if ( fetchGeometry )
   {
@@ -633,7 +632,7 @@
     OGR_G_DestroyGeometry( filter );
   }
 
-  setIgnoredFields( fetchGeometry, fetchAttributes );
+  setRelevantFields( fetchGeometry, fetchAttributes );
 
   //start with first feature
   OGR_L_ResetReading( ogrLayer );
@@ -875,6 +874,8 @@
 
 bool QgsOgrProvider::addFeatures( QgsFeatureList & flist )
 {
+  setRelevantFields( true, mAttributeFields.keys() );
+
   bool returnvalue = true;
   for ( QgsFeatureList::iterator it = flist.begin(); it != flist.end(); ++it )
   {
@@ -943,7 +944,7 @@
 
   clearMinMaxCache();
 
-  setIgnoredFields( true, QgsAttributeList() );
+  setRelevantFields( true, mAttributeFields.keys() );
 
   for ( QgsChangedAttributesMap::const_iterator it = attr_map.begin(); it != attr_map.end(); ++it )
   {
@@ -1014,7 +1015,7 @@
   OGRFeatureH theOGRFeature = 0;
   OGRGeometryH theNewGeometry = 0;
 
-  setIgnoredFields( true, QgsAttributeList() );
+  setRelevantFields( true, mAttributeFields.keys() );
 
   for ( QgsGeometryMap::iterator it = geometry_map.begin(); it != geometry_map.end(); ++it )
   {

Modified: trunk/qgis/src/providers/ogr/qgsogrprovider.h
===================================================================
--- trunk/qgis/src/providers/ogr/qgsogrprovider.h	2011-03-08 22:28:50 UTC (rev 15394)
+++ trunk/qgis/src/providers/ogr/qgsogrprovider.h	2011-03-08 23:05:25 UTC (rev 15395)
@@ -251,8 +251,8 @@
     /** find out the number of features of the whole layer */
     void recalculateFeatureCount();
 
-    /** tell OGR which fields not to fetch in nextFeature/featureAtId */
-    void setIgnoredFields( bool fetchGeometry, const QgsAttributeList& fetchAttributes );
+    /** tell OGR, which fields to fetch in nextFeature/featureAtId (ie. which not to ignore) */
+    void setRelevantFields( bool fetchGeometry, const QgsAttributeList& fetchAttributes );
 
   private:
     unsigned char *getGeometryPointer( OGRFeatureH fet );



More information about the QGIS-commit mailing list