[gdal-dev] OGRDataSource::CreateLayer error on application exit
Even Rouault
even.rouault at mines-paris.org
Fri Mar 29 14:00:33 PDT 2013
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() )
More information about the gdal-dev
mailing list