Ivan Willig wrote:
Hi list,
I am having an issues with using the python swig based bindings. I am on Fedora 13 using the default gdal rpm, which is at version 1.6.2. My issue is when i stack method calls. For example when I do the following:
ogr.Open("/home/ivan/dev/bigapps/data/nyco.shp").GetLayer().GetFeature(0)


I get a Segmentation fault. Here are the results of strace http://paste.pocoo.org/show/281682/. What am I doing wrong? Should I just hand compile a new version of gdal? Or is this not an advised usage of the python bindings? A limitation in swig? Thanks for your help.

Ivan,

I believe the problem is object lifetimes.  Keep a reference to the
datasource around until you are done with the feature(s).

ds = ogr.Open("/home/ivan/dev/bigapps/data/nyco.shp")
feat = ds.GetLayer().GetFeature(0)
...
feat = None
ds = None

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmer...@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to