Bug report #1248
QgsGeometry.Union causes Segfault when unioning multi-polyon features
|Affected QGIS version:||Regression?:||No|
|Operating System:||Linux||Easy fix?:||No|
|Pull Request or Patch supplied:||Resolution:||duplicate|
|Crashes QGIS or corrupts data:||Copied to github as #:||11308|
When unioning two features using QgsGeometry.Union, if one of the features is a multi-polygon, QGIS crashes without warning.
Example (should combine all geometries of a single layer together through unioning):
geom = QgsGeometry()
geom2 = QgsGeometry()
geom = feat.geometry()
geom2 = feat.geometry()
geom = geom.Union(geom2)
#1 Updated by Jürgen Fischer over 14 years ago
- Resolution set to duplicate
- Status changed from Open to Closed
Looks like this is the same problem as #777. Union is simply called with a geometry that has already been destructed.
getNextFeature deletes the geometry of the first feature and therefore the geometry you retrieved earlier becomes invalid.
If you copy the geometry the crash disappears:
geom = [[QgsGeometry]]() p = iface.getMapCanvas().currentLayer().dataProvider() f = [[QgsFeature]]() p.getNextFeature(f) geom = [[QgsGeometry]](f.geometry()) while p.getNextFeature(f): geom = geom.Union( f.geometry() ) f = [[QgsFeature]]() f.setGeometry( geom ) p.addFeatures([f])
#2 Updated by Anonymous over 13 years ago
Milestone Version 1.0.0 deleted