Skip to content

Commit

Permalink
Fix Polygon Centroids tool hangs on null geometry (fix #15045)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 17, 2016
1 parent c6457a6 commit b380a1d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions python/plugins/fTools/tools/doGeometry.py
Expand Up @@ -598,22 +598,22 @@ def polygon_centroids(self):
writer = QgsVectorFileWriter(self.myName, self.myEncoding, vprovider.fields(),
QGis.WKBPoint, vprovider.crs())
inFeat = QgsFeature()
outFeat = QgsFeature()
nFeat = vprovider.featureCount()
nElement = 0
self.emit(SIGNAL("runStatus( PyQt_PyObject )"), 0)
self.emit(SIGNAL("runRange( PyQt_PyObject )"), (0, nFeat))
fit = vprovider.getFeatures()
while fit.nextFeature(inFeat):
outFeat = QgsFeature()
nElement += 1
self.emit(SIGNAL("runStatus( PyQt_PyObject )"), nElement)
inGeom = inFeat.geometry()
if inFeat.constGeometry():
inGeom = inFeat.geometry()
outGeom = inGeom.centroid()
outFeat.setGeometry(QgsGeometry(outGeom))

atMap = inFeat.attributes()
outGeom = inGeom.centroid()
if outGeom is None:
return "math_error"
outFeat.setAttributes(atMap)
outFeat.setGeometry(QgsGeometry(outGeom))
writer.addFeature(outFeat)
del writer
return True
Expand Down

0 comments on commit b380a1d

Please sign in to comment.