[gdal-dev] OGRDataSource::CreateLayer error on application exit

Andy Canfield andy.canfield at gmail.com
Fri Mar 29 14:12:48 PDT 2013


On Fri, Mar 29, 2013 at 3:00 PM, Even Rouault
<even.rouault at mines-paris.org>wrote:

> Le vendredi 29 mars 2013 21:38:13, Andy Canfield a écrit :
> > If I create a shapefile layer like so:
> > const char *pszShpDriverName = "ESRI Shapefile";
> > OGRSFDriver *poShpDriver;
> > poShpDriver =
> > OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(pszShpDriverName);
> > poShpDS = poShpDriver->CreateDataSource(pszDstFilename, NULL);
> > poShpLayer = poShpDS->CreateLayer( "poly_out", NULL, wkbPolygon, NULL );
> >
> >
> > and close it like so:
> > OGRDataSource::DestroyDataSource(poShpDS);
> >
> >
> > I have no problems, but if I specify a projection for it from an open
> > GeoTiff I have
> > as the data set "poDataset" like so:
> >
> > OGRSpatialReference *poSrcSRS = new
> > OGRSpatialReference(poDataset->GetProjectionRef());
> >
> >
> > const char *pszShpDriverName = "ESRI Shapefile";
> > OGRSFDriver *poShpDriver;
> > poShpDriver =
> > OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(pszShpDriverName);
> > poShpDS = poShpDriver->CreateDataSource(pszDstFilename, NULL);
> > poShpLayer = poShpDS->CreateLayer( "poly_out", poSrcSRS, wkbPolygon, NULL
> > );
> >
> > I get this error when I go to shut my application down after using the
> > above code be it in a dll or in a console app.
>
> This is just a guess, but it might be related how you delete poSrcSRS. As
> you've allocated it with "new", you should delete it with "delete" (and not
> OGRSpatialReference::DestroySpatialReference() )
>

Calling delete or OGRSpatialReference::DestroySpatialReference() on
poSrcSRS both
throw an error even if I never use it, but it is a different error than the
one I am seeing currently on app shutdown.

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130329/e0265e9e/attachment.html>


More information about the gdal-dev mailing list