Skip to content

Commit

Permalink
QgsVectorFileWriter::createFeature(): remove useless and broken proce…
Browse files Browse the repository at this point in the history
…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 11, 2022
1 parent 285b101 commit 0b4939e
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -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 )
{
Expand Down

0 comments on commit 0b4939e

Please sign in to comment.