Bug report #1248
QgsGeometry.Union causes Segfault when unioning multi-polyon features
Status: | Closed | ||
---|---|---|---|
Priority: | Low | ||
Assignee: | Jürgen Fischer | ||
Category: | Vectors | ||
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 |
Description
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()
provider.getNextFeature(feat)
geom = feat.geometry()
while provider.getNextFeature(feat):
geom2 = feat.geometry()
geom = geom.Union(geom2)
History
#1 Updated by Jürgen Fischer over 16 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 15 years ago
Milestone Version 1.0.0 deleted