Skip to content

Commit

Permalink
Save as vector file: fix re-opening a GeoJSON Newline delimited file
Browse files Browse the repository at this point in the history
Fixes #58760
  • Loading branch information
rouault committed Sep 16, 2024
1 parent 4109c8d commit b43c7a7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@
//
// GDAL/OGR includes
//
#include <gdal.h>
#include <ogr_api.h>
#include <gdal_version.h>
#include <proj.h>
Expand Down Expand Up @@ -8638,9 +8639,23 @@ QString QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbology
QgsVectorFileWriterTask *writerTask = new QgsVectorFileWriterTask( vlayer, vectorFilename, options );

// when writer is successful:
connect( writerTask, &QgsVectorFileWriterTask::completed, this, [onSuccess, addToCanvas, encoding, vectorFilename]( const QString & newFilename, const QString & newLayer )
connect( writerTask, &QgsVectorFileWriterTask::completed, this, [onSuccess, addToCanvas, encoding, vectorFilename, format]( const QString & newFilename, const QString & newLayer )
{
onSuccess( newFilename, addToCanvas, newLayer, encoding, vectorFilename );
QString layerName = newLayer;
#ifdef GDAL_DCAP_MULTIPLE_VECTOR_LAYERS
GDALDriverH hDriver = GDALGetDriverByName( format.toUtf8().constData() );
if ( hDriver )
{
// If the driver doesn't advertize supporting multiple vector layers,
// do not attempt to append the layer name to the connection URI
// This would for example break for the GeoJSONSeq driver.
if ( !GDALGetMetadataItem( hDriver, GDAL_DCAP_MULTIPLE_VECTOR_LAYERS, nullptr ) )
{
layerName.clear();
}
}
#endif
onSuccess( newFilename, addToCanvas, layerName, encoding, vectorFilename );
} );

// when an error occurs:
Expand Down

0 comments on commit b43c7a7

Please sign in to comment.