mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
vector file writer: defer destroying spatial reference (fixes #10515)
This commit is contained in:
parent
6426be343f
commit
cee63c84f7
@ -69,6 +69,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
|
||||
)
|
||||
: mDS( NULL )
|
||||
, mLayer( NULL )
|
||||
, mOgrRef( NULL )
|
||||
, mGeom( NULL )
|
||||
, mError( NoError )
|
||||
, mCodec( 0 )
|
||||
@ -260,12 +261,11 @@ QgsVectorFileWriter::QgsVectorFileWriter(
|
||||
}
|
||||
|
||||
// consider spatial reference system of the layer
|
||||
OGRSpatialReferenceH ogrRef = NULL;
|
||||
if ( srs )
|
||||
{
|
||||
QString srsWkt = srs->toWkt();
|
||||
QgsDebugMsg( "WKT to save as is " + srsWkt );
|
||||
ogrRef = OSRNewSpatialReference( srsWkt.toLocal8Bit().data() );
|
||||
mOgrRef = OSRNewSpatialReference( srsWkt.toLocal8Bit().data() );
|
||||
}
|
||||
|
||||
// datasource created, now create the output layer
|
||||
@ -285,7 +285,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
|
||||
// disable encoding conversion of OGR Shapefile layer
|
||||
CPLSetConfigOption( "SHAPE_ENCODING", "" );
|
||||
|
||||
mLayer = OGR_DS_CreateLayer( mDS, TO8F( layerName ), ogrRef, wkbType, options );
|
||||
mLayer = OGR_DS_CreateLayer( mDS, TO8F( layerName ), mOgrRef, wkbType, options );
|
||||
|
||||
if ( options )
|
||||
{
|
||||
@ -318,8 +318,6 @@ QgsVectorFileWriter::QgsVectorFileWriter(
|
||||
QgsDebugMsg( "Couldn't open file " + layerName + ".qpj" );
|
||||
}
|
||||
}
|
||||
|
||||
OSRDestroySpatialReference( ogrRef );
|
||||
}
|
||||
|
||||
if ( mLayer == NULL )
|
||||
@ -1829,6 +1827,11 @@ QgsVectorFileWriter::~QgsVectorFileWriter()
|
||||
{
|
||||
OGR_DS_Destroy( mDS );
|
||||
}
|
||||
|
||||
if ( mOgrRef )
|
||||
{
|
||||
OSRDestroySpatialReference( mOgrRef );
|
||||
}
|
||||
}
|
||||
|
||||
QgsVectorFileWriter::WriterError
|
||||
|
@ -275,6 +275,7 @@ class CORE_EXPORT QgsVectorFileWriter
|
||||
|
||||
OGRDataSourceH mDS;
|
||||
OGRLayerH mLayer;
|
||||
OGRSpatialReferenceH mOgrRef;
|
||||
OGRGeometryH mGeom;
|
||||
|
||||
QgsFields mFields;
|
||||
|
Loading…
x
Reference in New Issue
Block a user