Opened 17 years ago
Last modified 14 years ago
#777 new bug
crashes with python reference to destroyed objects (e.g exportToWkt() crashes when geom has been deleted)
Reported by: | crschmidt | Owned by: | wonder |
---|---|---|---|
Priority: | major: does not work as expected | Milestone: | Version 1.7.0 |
Component: | Python plugins and bindings | Version: | Trunk |
Keywords: | Cc: | ||
Must Fix for Release: | No | Platform: | All |
Platform Version: | Awaiting user input: | no |
Description
When a feature is destroyed, if it has ownership over a geometry, it deletes that geometry. After that point, if one tries to call functions on the geometry, it will return nulls (Linux) or cause a KERN_PROTECTION_FAILURE (OS X).
This can be reproduced by selecting a feature, then typing the following into the Python console:
iface.activeLayer().selectedFeatures()[0].geometry().exportToWkt()
(Sometimes it requires calling it twice to reproduce the crash -- however, it will never return the correct answer.)
The reason for this appears to be that the feature created when it is pulled out of the list is then destoryed before exportToWkt() is called, taking the geometry with it.
A workaround is to instead call geometryAndOwnership(), which tells the feature to not destroy the geometry.
It seems like this problem may actually be exportGeosToWkb -- functions like wkbType() fail in the same way. It's possible that the mGeometry check at the beginning of these functions needs to move before teh exportGeosToWkb(), or that the exportGeosToWkb() needs to more resilient against being deleted.
Change History (10)
comment:1 by , 17 years ago
Owner: | changed from | to
---|
comment:4 by , 14 years ago
Milestone: | Version 1.0.3 |
---|---|
Platform: | OS X → All |
Platform Version: | 10.4.10 |
Summary: | exportToWkt() crashes when geom has been deleted → crashes with python reference to destroyed objects (e.g exportToWkt() crashes when geom has been deleted) |
see also #2173
comment:5 by , 14 years ago
Component: | Vectors → Python plugins and bindings |
---|
comment:6 by , 14 years ago
Milestone: | → Version 1.4.0 |
---|
comment:9 by , 14 years ago
Type: | defect → bug |
---|
comment:10 by , 14 years ago
No crashes in my Ubuntu 9.04, but I never get the correct results.
I tried wkbType() on the same selected geometry a lot of times and I get different (and also strange) results: 0, 16777216, 7, 187101, 92, 143587, ...
The problem here is in python bindings because the scenario seems to be like this:
I'm trying to find out how to cope with this correctly...
Martin