Bug report #13084
Segfault when accessing geometry from Python console
Status: | Closed | ||
---|---|---|---|
Priority: | High | ||
Assignee: | - | ||
Category: | PyQGIS Console | ||
Affected QGIS version: | master | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | duplicate |
Crashes QGIS or corrupts data: | Yes | Copied to github as #: | 21151 |
Description
Load the test data. Open python console. Run
iface.activeLayer().selectedFeatures()[0].geometry().exportToWkt()
Get
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f4a0b337dcc in QgsAbstractGeometryV2::wkbType (this=0x21) at /home/dbaston/dev/QGIS/src/core/geometry/qgsabstractgeometryv2.h:117
117 QgsWKBTypes::Type wkbType() const { return mWkbType; }
Not sure that the test data actually matters.
Build 8e488ca. Originally experienced the problem w/QGIS 2.6, where .exportToWkt() would produce an empty string and .asWkb() would dump random memory contents.
Related issues
History
#1 Updated by Daniel Baston over 9 years ago
- File test.zip added
#2 Updated by Martin Dobias over 9 years ago
- Resolution set to duplicate
- Status changed from Open to Closed
Duplicate of #777.
A solution is to keep temporary reference to the feature you work with:
f = iface.activeLayer().selectedFeatures()[0] print f.geometry().exportToWkt()
This will avoid destruction of QgsFeature instance while its QgsGeometry object is still in use.