mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-03 00:04:37 -05:00
Fixes crash when 'use selected' checkbox is check but no features are selected. Fixes #2504.
git-svn-id: http://svn.osgeo.org/qgis/trunk@13031 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
428b72812b
commit
f60dda6be9
@ -237,6 +237,7 @@ class visualThread( QThread ):
|
|||||||
if self.mySelection: # only selected features
|
if self.mySelection: # only selected features
|
||||||
selection = vlayer.selectedFeatures()
|
selection = vlayer.selectedFeatures()
|
||||||
nFeat = vlayer.selectedFeatureCount()
|
nFeat = vlayer.selectedFeatureCount()
|
||||||
|
if nFeat > 0:
|
||||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
|
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
|
||||||
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
|
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
|
||||||
for f in selection:
|
for f in selection:
|
||||||
@ -281,7 +282,7 @@ class visualThread( QThread ):
|
|||||||
nElement += 1
|
nElement += 1
|
||||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
|
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
|
||||||
nVal= float( len( values ) )
|
nVal= float( len( values ) )
|
||||||
if nVal > 0.00:
|
if nVal > 0:
|
||||||
meanVal = sumVal / nVal
|
meanVal = sumVal / nVal
|
||||||
lstStats = []
|
lstStats = []
|
||||||
lstStats.append( self.tr( "Max. len:" ) + unicode( maxVal ) )
|
lstStats.append( self.tr( "Max. len:" ) + unicode( maxVal ) )
|
||||||
@ -291,6 +292,8 @@ class visualThread( QThread ):
|
|||||||
lstStats.append( self.tr( "Empty:" ) + unicode( emptyVal ) )
|
lstStats.append( self.tr( "Empty:" ) + unicode( emptyVal ) )
|
||||||
lstStats.append( self.tr( "N:" ) + unicode( nVal ) )
|
lstStats.append( self.tr( "N:" ) + unicode( nVal ) )
|
||||||
return ( lstStats, [] )
|
return ( lstStats, [] )
|
||||||
|
else:
|
||||||
|
return ( ["Error:No features selected!"], [] )
|
||||||
else: # numeric field
|
else: # numeric field
|
||||||
stdVal = 0.00
|
stdVal = 0.00
|
||||||
cvVal = 0.00
|
cvVal = 0.00
|
||||||
@ -302,6 +305,7 @@ class visualThread( QThread ):
|
|||||||
selection = vlayer.selectedFeatures()
|
selection = vlayer.selectedFeatures()
|
||||||
nFeat = vlayer.selectedFeatureCount()
|
nFeat = vlayer.selectedFeatureCount()
|
||||||
uniqueVal = ftools_utils.getUniqueValuesCount( vlayer, index, True )
|
uniqueVal = ftools_utils.getUniqueValuesCount( vlayer, index, True )
|
||||||
|
if nFeat > 0:
|
||||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
|
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
|
||||||
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
|
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
|
||||||
for f in selection:
|
for f in selection:
|
||||||
@ -339,8 +343,8 @@ class visualThread( QThread ):
|
|||||||
nElement += 1
|
nElement += 1
|
||||||
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
|
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
|
||||||
nVal= float( len( values ) )
|
nVal= float( len( values ) )
|
||||||
rangeVal = maxVal - minVal
|
|
||||||
if nVal > 0.00:
|
if nVal > 0.00:
|
||||||
|
rangeVal = maxVal - minVal
|
||||||
meanVal = sumVal / nVal
|
meanVal = sumVal / nVal
|
||||||
if meanVal != 0.00:
|
if meanVal != 0.00:
|
||||||
for val in values:
|
for val in values:
|
||||||
@ -366,6 +370,8 @@ class visualThread( QThread ):
|
|||||||
lstStats.append( self.tr( "Range:" ) + unicode( rangeVal ) )
|
lstStats.append( self.tr( "Range:" ) + unicode( rangeVal ) )
|
||||||
lstStats.append( self.tr( "Median:" ) + unicode( medianVal ) )
|
lstStats.append( self.tr( "Median:" ) + unicode( medianVal ) )
|
||||||
return ( lstStats, [] )
|
return ( lstStats, [] )
|
||||||
|
else:
|
||||||
|
return ( ["Error:No features selected!"], [] )
|
||||||
|
|
||||||
def nearest_neighbour_analysis( self, vlayer ):
|
def nearest_neighbour_analysis( self, vlayer ):
|
||||||
vprovider = vlayer.dataProvider()
|
vprovider = vlayer.dataProvider()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user