Skip to content
Permalink
Browse files
QgsVectorFileWriter::createFeature(): remove useless and broken proce…
…ssing of feature id

891e665
changed the historical logic of always assigning the QGIS feature id as
a OGR feature id before calling OGR_L_CreateFeature(). But it actually change it in
a borken broken way by doing it only when the QGIS feature id was >
INT_MAX, and then it assigned the result of the cast of the value to long (which is
32 bit on windows), resulting in a negative value.

Just remove all that logic which is useless.

This is the root cause for an issue of exporting a subset of a very
large layer to XLSX/ODS reported in
https://lists.osgeo.org/pipermail/gdal-dev/2022-January/055202.html
  • Loading branch information
rouault authored and nyalldawson committed Jan 10, 2022
1 parent a219d28 commit 824e8ad8c69553a8431e8e5c76f5146aebdf1e72
Showing with 0 additions and 14 deletions.
  1. +0 −14 src/core/qgsvectorfilewriter.cpp
@@ -2426,20 +2426,6 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur

gdal::ogr_feature_unique_ptr poFeature( OGR_F_Create( OGR_L_GetLayerDefn( mLayer ) ) );

qint64 fid = FID_TO_NUMBER( feature.id() );
if ( fid > std::numeric_limits<int>::max() )
{
QgsDebugMsg( QStringLiteral( "feature id %1 too large." ).arg( fid ) );
OGRErr err = OGR_F_SetFID( poFeature.get(), static_cast<long>( fid ) );
if ( err != OGRERR_NONE )
{
QgsDebugMsg( QStringLiteral( "Failed to set feature id to %1: %2 (OGR error: %3)" )
.arg( feature.id() )
.arg( err ).arg( CPLGetLastErrorMsg() )
);
}
}

// attribute handling
for ( QMap<int, int>::const_iterator it = mAttrIdxToOgrIdx.constBegin(); it != mAttrIdxToOgrIdx.constEnd(); ++it )
{

0 comments on commit 824e8ad

Please sign in to comment.