[gdal-dev] postgis OGRFeature crash QGIS

Luca Delucchi lucadeluge at gmail.com
Wed Oct 7 05:57:55 PDT 2015


On 7 October 2015 at 13:18, Even Rouault <even.rouault at spatialys.com> wrote:

>
> Luca,
>

Hi Even,

> I'm not completely sure if this is the reason, but there's at least something
> to correct related to the use of:
>
> self.feat_defn.AddFieldDefn(style_field)
>
> Quoting OGRFeatureDefn::AddFieldDefn() documentation
> http://gdal.org/classOGRFeatureDefn.html#a40e681d8464b42f1a1fac655f16ac3dd :
>
> "To add a new field definition to a layer definition, do not use this function
> directly, but use OGRLayer::CreateField() instead."
>
> Hum actually looking more closely, I think the issue is that you modify the
> layer definition after having accumulated features in the "features"
> dictionary.
>
> Still quoting OGRFeatureDefn::AddFieldDefn() documentation
> "This method should only be called while there are no OGRFeature objects in
> existance based on this OGRFeatureDefn."
>
> So you should probably call outLayer.CreateField() before reading the postgres
> features.
>

CreateField works perfectly, I also removed the workaround for postgresql

Thanks a lot

> Even
>


-- 
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org


More information about the gdal-dev mailing list