[QGIS Commit] r13885 - trunk/qgis/python/plugins/fTools/tools

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Jul 4 14:03:34 EDT 2010


Author: cfarmer
Date: 2010-07-04 18:03:34 +0000 (Sun, 04 Jul 2010)
New Revision: 13885

Modified:
   trunk/qgis/python/plugins/fTools/tools/doSubsetSelect.py
Log:
Patch to fix (second problem) #2735. Patch thanks to brushtyler.

Modified: trunk/qgis/python/plugins/fTools/tools/doSubsetSelect.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doSubsetSelect.py	2010-07-04 16:27:26 UTC (rev 13884)
+++ trunk/qgis/python/plugins/fTools/tools/doSubsetSelect.py	2010-07-04 18:03:34 UTC (rev 13885)
@@ -82,9 +82,10 @@
         self.buttonOk.setEnabled( True )
 
     def compute(self, inVect, inField, value, perc, progressBar):
+        mlayer = ftools_utils.getMapLayerByName(inVect)
+        mlayer.removeSelection(True)
         vlayer = ftools_utils.getVectorLayerByName(inVect)
         vprovider = vlayer.dataProvider()
-        mlayer = ftools_utils.getMapLayerByName(inVect)
         allAttrs = vprovider.attributeIndexes()
         vprovider.select(allAttrs)
         index = vprovider.fieldNameIndex(inField)
@@ -93,7 +94,6 @@
         unique = ftools_utils.getUniqueValues(vprovider, int(index))
         inFeat = QgsFeature()
         selran = []
-        mlayer.removeSelection(True)
         nFeat = vprovider.featureCount() * len(unique)
         nElement = 0
         self.progressBar.setValue(0)
@@ -111,9 +111,9 @@
                     self.progressBar.setValue(nElement)
                 if perc: selVal = int(round((value / 100.0000) * len(FIDs), 0))
                 else: selVal = value
-                if selVal >= len(FIDs): selran = FIDs
-                else: selran = random.sample(FIDs, selVal)
-                selran.extend(mlayer.selectedFeaturesIds())
-                mlayer.setSelectedFeatures(selran)
+                if selVal >= len(FIDs): selFeat = FIDs
+                else: selFeat = random.sample(FIDs, selVal)
+                selran.extend(selFeat)
+            mlayer.setSelectedFeatures(selran)
         else:
             mlayer.setSelectedFeatures(range(0, mlayer.featureCount()))



More information about the QGIS-commit mailing list