[QGIS Commit] r10272 - in trunk/qgis/src: core providers/gpx providers/grass providers/memory providers/ogr providers/postgres providers/wfs

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Mar 11 19:45:23 EDT 2009


Author: cfarmer
Date: 2009-03-11 19:45:23 -0400 (Wed, 11 Mar 2009)
New Revision: 10272

Modified:
   trunk/qgis/src/core/qgsvectorlayer.cpp
   trunk/qgis/src/providers/gpx/qgsgpxprovider.cpp
   trunk/qgis/src/providers/grass/qgsgrassprovider.cpp
   trunk/qgis/src/providers/memory/qgsmemoryprovider.cpp
   trunk/qgis/src/providers/ogr/qgsogrprovider.cpp
   trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
   trunk/qgis/src/providers/wfs/qgswfsprovider.cpp
Log:
Ensures that features (properly) fetched from provider (via nextFeature) 
are set as valid
Ensures that only valid features are rendered on the map canvas


Modified: trunk/qgis/src/core/qgsvectorlayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.cpp	2009-03-11 22:32:49 UTC (rev 10271)
+++ trunk/qgis/src/core/qgsvectorlayer.cpp	2009-03-11 23:45:23 UTC (rev 10272)
@@ -3343,7 +3343,7 @@
   // used in all cases of the statement (otherwise they may get
   // executed, but never used, in a bit of code where performance is
   // critical).
-
+  if (! fet.isValid() ) { return; }
 #if defined(Q_WS_X11)
   bool needToTrim = false;
 #endif

Modified: trunk/qgis/src/providers/gpx/qgsgpxprovider.cpp
===================================================================
--- trunk/qgis/src/providers/gpx/qgsgpxprovider.cpp	2009-03-11 22:32:49 UTC (rev 10271)
+++ trunk/qgis/src/providers/gpx/qgsgpxprovider.cpp	2009-03-11 23:45:23 UTC (rev 10272)
@@ -129,6 +129,7 @@
 
 bool QgsGPXProvider::nextFeature( QgsFeature& feature )
 {
+  feature.setValid( false );
   bool result = false;
 
   QgsAttributeList::const_iterator iter;
@@ -403,6 +404,10 @@
 
     }
   }
+  if ( result )
+  {
+    feature.setValid( true );
+  }
   return result;
 }
 

Modified: trunk/qgis/src/providers/grass/qgsgrassprovider.cpp
===================================================================
--- trunk/qgis/src/providers/grass/qgsgrassprovider.cpp	2009-03-11 22:32:49 UTC (rev 10271)
+++ trunk/qgis/src/providers/grass/qgsgrassprovider.cpp	2009-03-11 23:45:23 UTC (rev 10272)
@@ -290,6 +290,7 @@
 
 bool QgsGrassProvider::nextFeature( QgsFeature& feature )
 {
+  feature.setValid( false );
   int cat, type, id;
   unsigned char *wkb;
   int wkbsize;
@@ -412,6 +413,8 @@
 
   setFeatureAttributes( mLayerId, cat, &feature, mAttributesToFetch );
 
+  feature.setValid( true );
+  
   return true;
 }
 

Modified: trunk/qgis/src/providers/memory/qgsmemoryprovider.cpp
===================================================================
--- trunk/qgis/src/providers/memory/qgsmemoryprovider.cpp	2009-03-11 22:32:49 UTC (rev 10271)
+++ trunk/qgis/src/providers/memory/qgsmemoryprovider.cpp	2009-03-11 23:45:23 UTC (rev 10272)
@@ -62,6 +62,7 @@
 
 bool QgsMemoryProvider::nextFeature( QgsFeature& feature )
 {
+  feature.setValid( false );
   bool hasFeature = FALSE;
 
   // option 1: using spatial index
@@ -128,8 +129,9 @@
   {
     feature = mSelectIterator.value();
     mSelectIterator++;
+    feature.setValid( true );
   }
-
+  
   return hasFeature;
 }
 

Modified: trunk/qgis/src/providers/ogr/qgsogrprovider.cpp
===================================================================
--- trunk/qgis/src/providers/ogr/qgsogrprovider.cpp	2009-03-11 22:32:49 UTC (rev 10271)
+++ trunk/qgis/src/providers/ogr/qgsogrprovider.cpp	2009-03-11 23:45:23 UTC (rev 10272)
@@ -341,6 +341,8 @@
 
 bool QgsOgrProvider::nextFeature( QgsFeature& feature )
 {
+  feature.setValid( false );
+  
   if ( !valid )
   {
     QgsLogger::warning( "Read attempt on an invalid shapefile data source" );
@@ -410,6 +412,7 @@
   if ( fet )
   {
     OGR_F_Destroy( fet );
+    feature.setValid( true );
     return true;
   }
   else

Modified: trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
===================================================================
--- trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp	2009-03-11 22:32:49 UTC (rev 10271)
+++ trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp	2009-03-11 23:45:23 UTC (rev 10272)
@@ -568,6 +568,7 @@
 
 bool QgsPostgresProvider::nextFeature( QgsFeature& feature )
 {
+  feature.setValid( false );
   QString cursorName = QString( "qgisf%1" ).arg( providerId );
 
   if ( !valid )
@@ -621,7 +622,8 @@
   feature.setAttributeMap( mFeatureQueue.front().attributeMap() );
 
   mFeatureQueue.pop();
-
+  
+  feature.setValid( true );
   return true;
 }
 

Modified: trunk/qgis/src/providers/wfs/qgswfsprovider.cpp
===================================================================
--- trunk/qgis/src/providers/wfs/qgswfsprovider.cpp	2009-03-11 22:32:49 UTC (rev 10271)
+++ trunk/qgis/src/providers/wfs/qgswfsprovider.cpp	2009-03-11 23:45:23 UTC (rev 10272)
@@ -65,6 +65,8 @@
 
 bool QgsWFSProvider::nextFeature( QgsFeature& feature )
 {
+  feature.setValid( false );
+  
   while ( true ) //go through the loop until we find a feature in the filter
   {
     if ( mSelectedFeatures.size() == 0 || mFeatureIterator == mSelectedFeatures.end() )
@@ -92,6 +94,7 @@
     {
       if ( feature.geometry() && feature.geometry()->intersects( mSpatialFilter ) )
       {
+        feature.setValid( true );
         return true;
       }
       else
@@ -101,6 +104,7 @@
     }
     else
     {
+      feature.setValid( true );
       return true;
     }
   }



More information about the QGIS-commit mailing list