#1248 closed bug (duplicate)
QgsGeometry.Union causes Segfault when unioning multi-polyon features
Reported by: | cfarmer | Owned by: | jef |
---|---|---|---|
Priority: | critical: causes crash or data corruption | Milestone: | |
Component: | Vectors | Version: | Trunk |
Keywords: | Cc: | ||
Must Fix for Release: | Yes | Platform: | Linux |
Platform Version: | Awaiting user input: | no |
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)
Note:
See TracTickets
for help on using tickets.
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: