[QGIS-trac] Re: [Quantum GIS] #1248: QgsGeometry.Union causes Segfault when unioning multi-polyon features

Quantum GIS qgis at qgis.org
Fri Aug 29 05:27:21 EDT 2008


#1248: QgsGeometry.Union causes Segfault when unioning multi-polyon features
--------------------------------------------------------------+-------------
        Reporter:  cfarmer                                    |         Owner:  jef          
            Type:  bug                                        |        Status:  closed       
        Priority:  critical: causes crash or data corruption  |     Milestone:  Version 1.0.0
       Component:  Vectors                                    |       Version:  HEAD         
      Resolution:  duplicate                                  |      Keywords:               
Platform_version:                                             |      Platform:  Linux        
        Must_fix:  Yes                                        |   Status_info:  0            
--------------------------------------------------------------+-------------
Changes (by jef):

  * status:  new => closed
  * resolution:  => duplicate

Comment:

 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])
 }}}

-- 
Ticket URL: <http://trac.osgeo.org/qgis/ticket/1248#comment:1>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list