@@ -86,7 +86,6 @@ QgsVectorFileWriter::QgsVectorFileWriter(
86
86
: mDS( nullptr )
87
87
, mLayer( nullptr )
88
88
, mOgrRef( nullptr )
89
- , mGeom( nullptr )
90
89
, mError( NoError )
91
90
, mCodec( nullptr )
92
91
, mWkbType( QGis::fromOldWkbType( geometryType ) )
@@ -103,7 +102,6 @@ QgsVectorFileWriter::QgsVectorFileWriter( const QString& vectorFileName, const Q
103
102
: mDS( nullptr )
104
103
, mLayer( nullptr )
105
104
, mOgrRef( nullptr )
106
- , mGeom( nullptr )
107
105
, mError( NoError )
108
106
, mCodec( nullptr )
109
107
, mWkbType( geometryType )
@@ -132,7 +130,6 @@ QgsVectorFileWriter::QgsVectorFileWriter( const QString& vectorFileName,
132
130
: mDS( nullptr )
133
131
, mLayer( nullptr )
134
132
, mOgrRef( nullptr )
135
- , mGeom( nullptr )
136
133
, mError( NoError )
137
134
, mCodec( nullptr )
138
135
, mWkbType( geometryType )
@@ -692,11 +689,6 @@ void QgsVectorFileWriter::init( QString vectorFileName,
692
689
QgsDebugMsg ( " Done creating fields" );
693
690
694
691
mWkbType = geometryType;
695
- if ( mWkbType != QgsWKBTypes::NoGeometry )
696
- {
697
- // create geometry which will be used for import
698
- mGeom = createEmptyGeometry ( mWkbType );
699
- }
700
692
701
693
if ( newFilename )
702
694
*newFilename = vectorFileName;
@@ -2133,7 +2125,9 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
2133
2125
}
2134
2126
else // wkb type matches
2135
2127
{
2136
- OGRErr err = OGR_G_ImportFromWkb ( mGeom , const_cast <unsigned char *>( geom->asWkb () ), static_cast < int >( geom->wkbSize () ) );
2128
+ OGRGeometryH ogrGeom = createEmptyGeometry ( mWkbType );
2129
+ OGRErr err = OGR_G_ImportFromWkb ( ogrGeom, const_cast <unsigned char *>( geom->asWkb () ), static_cast < int >( geom->wkbSize () ) );
2130
+
2137
2131
if ( err != OGRERR_NONE )
2138
2132
{
2139
2133
mErrorMessage = QObject::tr ( " Feature geometry not imported (OGR error: %1)" )
@@ -2144,8 +2138,8 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
2144
2138
return nullptr ;
2145
2139
}
2146
2140
2147
- // set geometry (ownership is not passed to OGR)
2148
- OGR_F_SetGeometry ( poFeature, mGeom );
2141
+ // set geometry (ownership is passed to OGR)
2142
+ OGR_F_SetGeometryDirectly ( poFeature, ogrGeom );
2149
2143
}
2150
2144
}
2151
2145
else
@@ -2182,11 +2176,6 @@ bool QgsVectorFileWriter::writeFeature( OGRLayerH layer, OGRFeatureH feature )
2182
2176
2183
2177
QgsVectorFileWriter::~QgsVectorFileWriter ()
2184
2178
{
2185
- if ( mGeom )
2186
- {
2187
- OGR_G_DestroyGeometry ( mGeom );
2188
- }
2189
-
2190
2179
if ( mDS )
2191
2180
{
2192
2181
OGR_DS_Destroy ( mDS );
0 commit comments