Thanks Jason, I will add my examples when I get a chance. Ivan Willig
On Tue, Oct 26, 2010 at 10:59 AM, Jason Roberts <jason.robe...@duke.edu>wrote: > Ivan, Frank, > > > > A month ago I started a gotchas page with Even Rouault that discusses this > issue: http://trac.osgeo.org/gdal/wiki/PythonGotchas. If you have a > moment, please consider adding your examples as other cases that cause the > lifetime problem. Also (Frank) if there is any general advice you wish to > add, it would be greatly appreciated. > > > > Best, > > Jason > > > > *From:* gdal-dev-boun...@lists.osgeo.org [mailto: > gdal-dev-boun...@lists.osgeo.org] *On Behalf Of *Ivan Willig > *Sent:* Tuesday, October 26, 2010 10:54 AM > *To:* Frank Warmerdam > *Cc:* gdal-dev@lists.osgeo.org > *Subject:* Re: [gdal-dev] Issue with python bindings. > > > > Thanks Frank. That seems to be the issue. Whats the rule about this how > long you should keep a reference. For example this causes the same issue. > > > > ds.GetLayer().GetFeature(0).GetGeometryRef().GetEnvelope() > > > > Which I am going to guess is because I should keep a reference to the > geometry. Correct? > > > Ivan Willig > > > > > On Tue, Oct 26, 2010 at 10:44 AM, Frank Warmerdam <warmer...@pobox.com> > wrote: > > 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